我有一个补间效果,适用于点击事件,但我希望它与期刊一起使用。请帮忙!提前谢谢。
// 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);
答案 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);