Skip to main content

页面元素渐入渐出的javascript代码

Firefox only

javascirpt:

function OpacityElement(element)
{
this.targetElement = element;
this.opacity = 1.0;
this.display = null;
}

OpacityElement.prototype =
{
intervalFun: null
,
timeoutFun: null
,
handleEvent: function(t)
{
switch(t)
{
case 1:
this.opacity -= 0.04;
this.targetElement.style.opacity = this.opacity;
break;
case 2:
this.opacity = 0.0;
this.targetElement.style.opacity = 0.0;
this.display = this.targetElement.style.display;
this.targetElement.style.display = 'none';
clearInterval(this.intervlaFun);
clearTimeout(this.timeoutFun);
break;
case 3:
this.opacity += 0.04;
this.targetElement.style.opacity = this.opacity;
break;
case 4:
this.opacity = 1.0;
this.targetElement.style.opacity = 1.0;
clearInterval(this.intervlaFun);
clearTimeout(this.timeoutFun);
break;
}
}
,
Hidden: function()
{
var self = this;
this.intervlaFun = setInterval( function() { self.handleEvent(1); }, 41);
this.timeoutFun = setTimeout( function() { self.handleEvent(2); }, 1000);
}
,
Show: function()
{
var self = this;
this.targetElement.style.display = this.display;
this.intervlaFun = setInterval( function() { self.handleEvent(3); }, 41);
this.timeoutFun = setTimeout( function() { self.handleEvent(4); },
1000);
}
}

}

在html中的使用

<script type="text/javascript">
var op = new OpacityElement(document.getElementById('itemId'));
document.getElementById('btnHidden').addEventListener('click', function () { op.Hidden();
}, false);
document.getElementById('btnShow').addEventListener('click', function () { op.Show();
}, false);
</script>

Comments

Popular posts from this blog

PSP 三国无双 大蛇传 人物图片

PSP三国无双 大蛇传 人物图片(Google Picasa相册) 现在还不全,太多了。。。(2008-03-23) 搞完了,体力活啊。(2008-04-20) 暂时放弃吧,那个空间到期很久了,忘了更新这里了。什么时候找到地方放再跟新。(2009-04-29) 上传到Google Picasa(2009-09-25)

一点感想

久久没来,最近在家google基本无法使用了,无奈用自由门翻墙而出,看到自己以前所发的东西,感慨良多。想起硬盘上魔兽截图无数,说不定哪天出个意外,不如发帖留恋。

Google Notebook整合了Google 书签

FF上一直装有Google笔记本的插件,一直没有到一面上去看,今天无意点到。发现多了个叫“Unfiled”的记事本,记得自己并未建过这么个东西,进去一看才发现,其实就是我的Google书签: 并且右下角也多了“Labels”,且与我Google书签中的相同。 其实人家的右上角的“ New features! ”里说得很清楚: Integration with Google Bookmarks Notebook is now integrated with Google Bookmarks. Your bookmarks will show up as a special Unfiled notebook, making Google Notebook a single place to collect and organize interesting web pages. To publish and collaborate, just drag and drop bookmarks into notebooks.