0

Mootools:如何在2 秒morpha.start()后获得? mouseenter

window.addEvent('domready',function() {
var morph = new Fx.Morph('resize',{duration:700,delay:400});
$$('#resize').addEvent('mouseenter',function(e){
    e.stop();
    morpha.start({
        width: '200px',
        height: '100px'
    });
}//It does not work on adding ',2000' here
);

<div id="resize" class="resize">DIV will get bigger after 2sec on mouseenter</div>
4

1 回答 1

1

使用延迟。

http://www.jsfiddle.net/dimitar/m6JKt/例子

document.id('resize').set("morph", {duration:700,delay:400}).addEvents({
    mouseenter: function(){
        this.store("timer", (function() {
            this.morph({
                width: '200px',
                height: '100px'
            });
        }).delay(2000, this));
    },
    mouseleave: function() {
        $clear(this.retrieve("timer"));
    }
});

这也被重构为使用为您执行类实例的 element.morph - 如果您在 2 秒的起始周期宽限期内鼠标悬停,它将取消转换。

于 2010-07-11T00:30:21.517 回答