javascript - Applied tween inside each(), how do I use reverse()? -
let's suppose apply tween each element on canvas
elements.each(function (element) { new kinetic.tween({ node: element, rotationdeg: 180 }).play(); });
all items have been tweened , have passed original state final state. question is: how apply reverse() revert each item original state?
store tweens inside array, , loop through array , use .reverse()
elements = stage.get('rect'); var tweenarray = []; // reverse tween document.getelementbyid('reverse').addeventlistener('click', function () { (var i=0; i<tweenarray.length; i++) { tweenarray[i].reverse(); } }, false); // play tween forward document.getelementbyid('play').addeventlistener('click', function () { elements.each(function (element) { var tween = new kinetic.tween({ node: element, rotationdeg: 180 }).play(); tweenarray.push(tween); }); }, false);
Comments
Post a Comment