+ 2
Help : ') Javascript
var pos = 0; //our box element var box = document.getElementById("box"); var t = setInterval(move, 10); function move() { if(pos >= 150) { clearInterval(t); } else { pos += 1; box.style.left = pos+"px"; } } -------------------------------------------------------------- "(move, 10);"? for what this '10' ? why 10 ?
3 Respuestas
+ 3
You’re right
+ 2
Ahhhh, so that is duration.... Thanks Toni :D
+ 2
Actually, it moves 1px every 10ms. So:
10ms = 1px;
100ms = 10px;
1000ms (1 second) = 100px.
Safe to say since it is 150px, it will be 1500ms or 1.5 seconds.
This animation is 1.5 seconds in length.