This project is archived and is in readonly mode.

#637 ✓resolved
Atmos4

getCoordinates()/getLeft()/getTop() bug on overflow:hidden elements

Reported by Atmos4 | April 17th, 2009 @ 09:54 AM | in 1.3.0 rc2 (closed)

I've discovered a bug in mootools-core-1.2.2-head (2009-04-17) and older versions (1.2, 1.2.1 tested).

If you call getCoordinates() on an element that has style="overflow:hidden" and the content of this element is scrolled (eg. by using -more class Scroller), getCoordinates() will return the coordinates of the overflown content inside the element, instead of the elements position on the page, as can be read from offsetLeft/offsetTop.

I've created a minimal testcase, scroll around by moving the mouse to the edges of the red box (box1, outer box), to see how the values of getCoordinates() and getLeft()/getTop() change.

http://atmosfear.nctec.net/mooto...

Expected behaviour would be for getCoordinates/getLeft/getTop to return identical values to offsetLeft/offsetTop.

The bug appeared both in WebKit nightly and Firefox 3.0.7 on Mac OS X 10.5.6.

Comments and changes to this ticket

  • Atmos4

    Atmos4 April 17th, 2009 @ 01:12 PM

    Notice, that I'm using getPosition() in the testcase, because it's what gets called by getCoordinates() further down the chain and is causing the problem.

  • Atmos4

    Atmos4 April 17th, 2009 @ 01:17 PM

    • Tag changed from core, element, getcoordinates, getleft, gettop to core, element, getcoordinates, getleft, getposition, gettop
  • Daniele C.

    Daniele C. April 17th, 2009 @ 02:09 PM

    I've an idea: maybe I'm wrong, but the getScroll function, that is

    
    getScrolls: function(){
      var element = this, position = {x: 0, y: 0};
      while (element && !isBody(element)){
        position.x += element.scrollLeft;
        position.y += element.scrollTop;
        element = element.parentNode;
      }
      return position;
    },
    

    I think that is not correct because I add the scroll of the current element too, but the scrollLeft and the scroolTop of the current element is not how much the CONTENT of the element is scrolled?

    I think it could be better:

    
    getScrolls: function(){
      var element = /*START CHANGES*/this.parentNode/*END CHANGES*/, 
      position = {x: 0, y: 0};
      while (element && !isBody(element)){
        position.x += element.scrollLeft;
        position.y += element.scrollTop;
        element = element.parentNode;
      }
      return position;
    },
    
  • Atmos4

    Atmos4 April 17th, 2009 @ 02:33 PM

    The above change would indeed fix the problem.

  • fakedarren

    fakedarren February 8th, 2010 @ 05:30 PM

    • State changed from “new” to “hold”
    • Assigned user set to “fakedarren”
    • Milestone changed from 2.0 to 1.3.0 rc2

    Putting on hold until I can confirm this wasn't fixed with changes made to offsets code in last release. If any of you watching this ticket can produce a shell to confirm / deny this as an issue in mooshell it would be much appreciated.

  • fakedarren

    fakedarren February 15th, 2010 @ 10:45 PM

    • State changed from “hold” to “resolved”

    Assuming resolved

    Unless you can provide a shell to prove stil an issue

    Changes to offsets will almost certainly result in different behaviour.

  • gonchuki

    gonchuki September 9th, 2010 @ 03:18 PM

    • Milestone order changed from “0” to “0”

    Take a look at #952. This should be fixed as soon as the commit is pulled into master.

Create your profile

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

Shared Ticket Bins

Referenced by

Pages