Hello, i cant seem to figure out this even though i have before :S
Im making a drag n drop script and want the object im dragging to be dragged from the point relative to where the mouse is positioned on the element.
I though this should be somewhat the way to calculate it, but this wont move the element one pixel. If i put + 1 right before + ‘px’ it moves, but not correctly since it will increment 1 extra pixel every mouse movement. Please can anyone check it out? (this is only the relevant piece of code….)
[CODE]
this.onmousemove = function(e) {
e = dsDyn.drag.fixE(e);
this.style.left = e.clientX – (e.clientX – target.offsetLeft) + ‘px’;
this.style.top = e.clientY – (e.clienty – target.offsetTop) + ‘px’;
}