This project is archived and is in readonly mode.

#698 ✓resolved
Lim Chee Aun

getOffsets returning wrong values on 1.2.3

Reported by Lim Chee Aun | June 30th, 2009 @ 12:16 AM | in 2.0 (closed)

I found a regression in Element.Dimensions getOffsets function which it returns different x,y values in 1.2.3 as compared to 1.2.2. I've put up two test cases where the values are different when calculating offsets of a block element inside an offset parent element.

I've tested that this bug happens on Firefox 3, 3.5beta, Opera 10 beta, and Safari 4 on Windows Vista. And probably due to this commit: http://github.com/mootools/mootools-core/commit/aa3cef0b9e065f08f50...

This bug also affects other plugin(s) like Fx.Scroll in MooTools More.

Comments and changes to this ticket

  • Shawn Tice

    Shawn Tice July 3rd, 2009 @ 01:02 AM

    I can second the issue on FF 3.5 and the WebKit nightly, and shed a little more light, I hope.

    I think the problem is the use of parseInt rather than Math.round to turn the values returned by getBoundingClientRect into integers. The browser (at least, FF 3.5) appears to round while MooTools truncates, resulting in an incorrect answer. So even in the very simple case of an element whose offsetParent is the document body, if the 'left' or 'top' values returned by getBoundingClientRect would round up rather than down, MooTools's getOffsets is off by one.

    In my case, el.getBoundingClientRect().top was 404.98333740234375, el.offsetTop
    was 405, and el.getOffsets().y was 404. Changing parseInt to Math.round gave correct answers for getOffsets in both FF 3.5 and IE7.

  • Fábio M. Costa

    Fábio M. Costa August 4th, 2009 @ 12:49 AM

    Lim, the 1.2.3 version is the one thats giving the correct values.
    Isnt it?
    Ive tested your page with another framework and it is giving values that are igual to the ones of 1.2.3 version.

  • Kenton

    Kenton August 18th, 2009 @ 12:28 AM

    Looks like a dupe of this issue: https://mootools.lighthouseapp.com/projects/2706/tickets/461-getoff..., it was previously just broken on IE, now it is broken on all browsers

  • Christoph Pojer

    Christoph Pojer December 18th, 2009 @ 01:01 AM

    • State changed from “new” to “resolved”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Pages