javascript - style change and setTimeout issues -


i want move element across screen changing style.left value , using settimeout() control change interval.

to start sequence using settimeout function in body onload.

then @ end of function doing delayed recall of same function continue sequence.

the problem appears style.left value change causes reload causes onload timer fire again. element flashes across screen final position open page tho timeout delay 5 seconds. ??

i aware of newer css animation techniques, not fit need.

is above paragraph correct assumption??

the biggest issue here using settimeout instead of setinterval. accomplish setinterval. including jsfiddle example: http://jsfiddle.net/33n99haj/1/

<div id="box" style="width:30px;height:30px;background-color:red;position:absolute;"></div>  window.e = document.getelementbyid("box"); var = 0;  setinterval(function () {     = + 20;     window.e.style.left = + "px";; },1000); 

don't forget position should absolute in css


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -