admin管理员组文章数量:1401133
I want to create a mouse rollover effect, like we used to see in flash websites - when the mouse rolls over an element it begins to animate, but if in the middle of the anim the mouse rolls out the animation would stop and run back.
I would like to achieve the same effect with fabric, but I can seem to find a way to stop the animation. For example:
rect.animate('top', '200', {
duration: 1000,
onChange: canvas.renderAll.bind(canvas),
onComplete: function() {
//callback code goes here
}
});
This will animate until the top
value of the rect
will bee 200
. Is there a way to stop animation before that?
I want to create a mouse rollover effect, like we used to see in flash websites - when the mouse rolls over an element it begins to animate, but if in the middle of the anim the mouse rolls out the animation would stop and run back.
I would like to achieve the same effect with fabric, but I can seem to find a way to stop the animation. For example:
rect.animate('top', '200', {
duration: 1000,
onChange: canvas.renderAll.bind(canvas),
onComplete: function() {
//callback code goes here
}
});
This will animate until the top
value of the rect
will bee 200
. Is there a way to stop animation before that?
1 Answer
Reset to default 9You need to specify abort
function.
rect.animate('top', '200', {
duration: 1000,
onChange: canvas.renderAll.bind(canvas),
onComplete: function() {
//callback code goes here
},
abort: function(){
return someConditionWhichAbortsAnimationWhenItsTrue;
}
});
The only problem is that abort
was not passed in to the underlying fabric.util.animate
, which I just fixed, so you'll need to use latest version :)
本文标签: javascriptHow to stop (in order to reverse) a fabricjs animationStack Overflow
版权声明:本文标题:javascript - How to stop (in order to reverse) a fabricjs animation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744280704a2598636.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论