Mootools的补间和期刊可比性

时间:2014-02-02 19:54:54

标签: mootools tween

我有一个补间效果,适用于点击事件,但我希望它与期刊一起使用。请帮忙!提前谢谢。

// Tween effect
var bounce = function() {
    this.set('tween', {duration: 1500, transition: 'bounce:out'});
    this.tween('right', [900, 40]);
}

// This works fine
$('someID').addEvent('click', bounce);

// These don't work
bounce();
bounce.periodical(10000);

1 个答案:

答案 0 :(得分:1)

bounce()附加到click事件后,您可以在该函数中使用this,但除此之外,您需要定义“this”。您可以使用bind,或将this更改为您的元素。

试试这个:

var bounce = function() {
    var element = $('someID'); // cache it here or outside the function
    element.set('tween', {duration: 1500, transition: 'bounce:out'});
    element.tween('right', [900, 40]);
}

bounce();
bounce.periodical(10000);