Hallo zusammen,
zu verschieben von divs verwende ich die lib von Walter Zorn, Anwendung Bsp.:
http://www.walterzorn.com/dragdrop/demos/dnd_snapandsort.htm
Beim verschieben der Divs benötige ich die alte und die neue Position des Div, die neue Postion kann ich über die Variable "var i = (y-margTop)/dy;" auslesen, leider weiß ich nicht wie ich an die alte Position des gerade verschobenen Divs kommen, jemand eine Idess?
Hier die Funktion :
[code=javascript]
function my_DropFunc()
{
// Calculate the snap position which is closest to the drop coordinates
var y = dd.obj.y+dy/2;
y = Math.max(margTop, Math.min(y - (y-margTop)%dy, margTop + (aElts.length-1)*dy));
//var OldPos = Math.max(posOld, Math.min(y - (y-posOld)%dy, posOld + (aElts.length-1)*dy));
// Index of the new position within the spatial order of all items
var i = (y-margTop)/dy; // <--------- die neue Position
// Interchange the positions of the two items
aElts[i].moveTo(100, posOld);
// Let the dropped item snap to position
dd.obj.moveTo(100, y);
// Update the array according to the changed succession of items
aElts[(posOld-margTop)/dy] = aElts[i];
aElts[i] = dd.obj;
}
[/code]
Grüße anton