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# - Attribute value in root node of xml Linq to XML -

ios swift - uiimage array to video disorted and flipped -

scala, transform a callback pattern to a functional style internal iterator -