+ 2
Guys this questions is related to JavaScript?
(1) how can i reverse the animation of increasing box to its actual position to the start=2 base, i know its confusing for you all , have a look in it. (2) How can i make a pause button by which i can stop it in any desired point. explain with a example. https://code.sololearn.com/WKubPu9UtB13/?ref=app
5 Respostas
+ 3
Check the following code:
https://code.sololearn.com/Wjq5Xg3kYwUA/?ref=app
I've minimal modified (and commented) yours for reaching your expects:
(1) modified your main JS function, adding some global vars...
(2) replaced your initial button with another one handling start/pause/resume and adding a function to handle it, separatly of your main function dedicated to the animation...
+ 2
Test for your condition, and if true exit function ( return ) without calling setTimeout()...
Obviously, set context as needed: in your actual modified example, set the related flags and button label (innerHTML value) according to the new state (paused) to let the user able to start again the animation ^^
+ 1
@Visph if i want to stop any animation at particular
point like a box should rise from 0 px to 100px and than it should stop there no further moment should take. so how can i do that.
+ 1
Visph i need your help please help me .
actually (1) i want to make a box in which if i click
a button the box should move from -200 px to 0 px,
it should stop on reaching to 0px
(2) if i click on the same Button once again it should again back to it's initial position to -200 px
Here is my code please tell me what is wrong in it and if possible pleases correct it with comments .
https://code.sololearn.com/Wf1i0r32xrjx/?ref=app
+ 1
Please tell me how to control the set time method
suppose if i want to stop the animation on a given point . please explain me with a simple example of code.