javascript - Double click run interval indefinitely -


i trying create animation using series of images. when clicks button iterate images interval & stops on condition current image number clearinterval. issue when clicks in series on buttons iteration becomes un-stoppable , runs indefinitely. clearinterval won't works then.

i have created jsfiddle well.

please me fix , let me know if not clear. in advance.

you need call clearinterval before call setinterval again. otherwise overwriting interval id of first call , never clear it.

alternatively, can keep track of whether or not interval still going , create new 1 if previous has finished. perhaps set loop -1 when call clearinterval , call setinterval if loop -1.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -