2010-01-09 119 views
2

我有一个Element对象,我目前正在调用.hide()。相反,我希望将整个元素(及其子元素)的不透明度淡出为100%(隐藏),作为500 ms或1000 ms的过渡效果。MooTools:淡出元素?

可以使用Fx.Tween吗?这是否可能 - MooTools框架在它的UI库中有这样的效果吗?

回答

2

使用

$('myElement').fade('toggle')`; 

它会自动淡入和淡出根据其状态的对象。

实施例:HTML

<div style='background-color:black;color:white' id="tweener"> 
     HELLO WORLD 
    </div> 

    <button onclick="javascript:doTween()">TWEEN</button> 

<script type='text/javascript'> 
    function doTween() 
    { 

     $('tweener').fade('toggle'); // out, in are other options available. 
    } 
</script> 
1

MooTools在它的FX.Tween软件包中有一个fade()方法,如here所示。

3
$('myElement').fade(0.7); 

将元素不透明度设置为70%。或

$('myElement').fade('out'); // fades the element out. 

http://mootools.net/docs/core/Fx/Fx.Tween#Element:fade

元法:褪色
元素快捷键与透明度调整 方法。有用的 用于淡入一个元素进出,或者对某个不透明度级别为 。