Tween Control on pressing buttons
Tween Control on pressing buttons Tween’s have a number of methods for controlling playback. In order to control a tween you need have way to reference it. Below we set up a variable to reference our tween. let mytween = gsap . to ( ".box1" , { y : 200 , paused : "true" , duration : 6 }) document . querySelector ( ".startBtn" ). onclick = function (){ mytween . play (); } document . querySelector ( ".pauseBtn" ). onclick = function (){ mytween . pause (); } document . querySelector ( ".restartBtn" ). onclick = function (){ mytween . restart (); } document . querySelector ( ".reverseBtn" ). onclick = function (){ mytween . reverse (); } we have created our animating object along with 4 buttons with html, and on clicking each button, the tween will behave. To do this we must set variable for our tween. We have set; Pause = "True" at beginning because if we dont k...



Comments
Post a Comment