Moving a div layer with JavaScript

Formula and example included.

Pseudo formula:

New style.left = MovingMouseX-(PushedMouseX-PreviousStyleLeft)
New style.top = MovingMouseY-(PushedMouseY-PreviousStyleTop)


With this formula you will move the layer relative to where you clicked on it.

Click on and hold, to move this layer.


Just view the source to see the code.

Written by: Dag Jonny Nedrelid
©2007-2012 http://thronic.com


Feel free to leave a comment.
Name:
URL:
0