Drag Object - make things draggable
What is Drag Object
Drag is a Javascript object which make things draggable as your wish.
You can restrict the region and direction an object can be dragged.
How to use it
There are several way to make an object draggable.
You can write directly in the tag:
<div onmousedown="return eval(Dragger);"></div>
In this case no extra parameters are given, just put "
return eval(Dragger);"
in your onmousedown handler.
When parameters are given, you can write it as :
<div onmousedown="return eval(Drag.init(this,mode,minx,miny,maxx,maxy));"/>
minx, miny, maxx, maxy constraint the region this object can go.
mode set
the direction of dragging; mode=1 for horizontal, mode=2 for vertical move.
You can also make an object draggabl in pure javascript :
var foo = document.getElementById("foo");
Drag.init(foo,0,300,300,500,500);
The parameters are the same as above.
Example
Try to drag the little green block below.