在动画结束之前执行Tweenmax回调

hju*_*ter 2 animation callback tweenlite tweenmax

我在我的网站上使用greensock gsap进行动画制作.问题是在动画结束之前执行的回调.在下面的示例中,元素被移动到动画的一半上的某处.

TweenLite.to($(".flipper"), 2, {rotationY:180,onComplete:function(){
    $(this).remove()
}});
Run Code Online (Sandbox Code Playgroud)

有没有人遇到过同样的问题?

Ser*_*rev 5

不,对我来说很好(见下面的jsfiddle).但是,this在你的回调函数不是你的动画对象,它是补间.因此,this.target如果要在动画后删除它,则必须使用,如下所示:

TweenLite.to($(".flipper"), 1, {rotationY:180,onComplete:function(){
    (this.target).remove()
}});
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/brian_griffin/5Ltfg/