list_order (Entry Nr. 42, by user 1 | edit) |
|
|
| // This shall become a tool to order items in a list.
// One will be able to select multiple items and drag them around.
// I picture nifty flying words the magically find their place.
ge_require_once('http://javascript.gibney.org/2d.js');
function mglo_element_mousedown(id)
{
if (Items[id].selected!=true)
{
if (mg_keys_keyPressed!=16)
{
for (i=0;i keep selection (to select multiple elements)
{
Items[id].selected=false;
mg_setElementClass("mglo_"+id,"div_mglo_item");
ItemSwarm.Elements["mglo_"+id].FollowAim=true;
}
*/
}
else
{
}
}
function mglo_mouseDown(e)
{
if (!e) e=event; // browser detection.
mglo_drag_start_y=e.screenY;
document.onmousemove=mglo_drag;
for (i=0;i0 && y_dif>0))
{
if ((Math.abs(dist)-Math.abs(y_dif))<20)
{
x_dist=ItemSwarm.Elements["mglo_"+i2].x-ItemSwarm.Elements["mglo_"+i].x;
Aim1=ItemSwarm.Elements["mglo_"+i].AimY;
ItemSwarm.Elements["mglo_"+i].AimY=Aim2;
ItemSwarm.Elements["mglo_"+i2].AimY=Aim1;
SpeedX=y_dif*6;
SpeedY=y_dif;
if (Math.abs(x_dist)>10)
{
SpeedX=0;
SpeedY=0;
}
if (SpeedX> 20) SpeedX= 20;
if (SpeedX<-20) SpeedX=-20;
if (SpeedY> 20) SpeedY= 20;
if (SpeedY<-20) SpeedY=-20;
ItemSwarm.Elements["mglo_"+i2].SpeedX+=SpeedX;
ItemSwarm.Elements["mglo_"+i2].SpeedY+=SpeedY;
}
}
}
}
ItemSwarm.Elements["mglo_"+i].y+=y_dif;
ItemSwarm.Elements["mglo_"+i].redraw();
}
function mglo_mouseUp()
{
document.onmousemove=mglo_dragNot;
for (i=0;i |
|
|
Create a new entry at this position
|
|
|