简体   繁体   中英

Get new position of element after Mootools Drag completes

I want to get the value of the left positioning or margin-left or something that shows how far left the div element has been dragged. I don't know howto access it. Trying to get 'left' just shows auto.

http://jsfiddle.net/nicekiwi/ZzwNt/1/

Is it even possible?

Say I drag the image 20px to the right, I want the alert box in onComplete to return the value of 20. Hope you get the idea.

I've tried using el.getComputedSize.computedLeft, but it just returns 0.

Mootools 1.4

Thanks.

I think the getScroll() function is what you're looking for, as this returns the amount that your containing div has been scrolled from top left.

onComplete: function(el){
    var imgPosition = el.getScroll();
    console.log(imgPosition.x);
    console.log(imgPosition.y);
}

Here's the updated fiddle as an example - http://jsfiddle.net/ZzwNt/2/

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM