hairybobby — 2011-07-31T18:41:27-04:00 — #1
I used to have a script that moved a div according to the mouse. I also used a timer. I used the following formula to move the div.
new position = ((old position * 9)+ current mouse position)/10
Its particularly effective as you slowly move to the new position. Its recalculated every lets say tenth of a second.
My question is
1. how do I move a div every tenth of a second
2. How do calculate the current mouse position
paul_wilkins — 2011-07-31T21:07:51-04:00 — #2
By using setInterval to run a function every 100 milliseconds.
With difficulty. The full details are covered at the [event properties page, specifically, in the [url="http://www.quirksmode.org/js/events_properties.html#position"]mouse position](http://www.quirksmode.org/js/events_properties.html) section of the page.