Does setTimeout
work from WITHIN setInterval
?
I'm writing some JavaScript to animate some DOM elements for a strange artistic project. The best way for me to explain my question is to give an example:
I have 50 different divs that I need to animate by changing their position on screen, using setInterval
. I need each div to be moving at a different rate.
The solution I planned to use was to have a sleep function within my larger changePosition function, so that I could pass a different sleep value for each div. This way, I could assign a unique rate of movement for each div via a dictionary.
The issue that I'm having is that JavaScript does not have "sleep". It only has setTimeout
, which does not seem to be working from within my setInterval
loop.