Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2011
    Location
    Moscow, Russia
    Posts
    18
    Vote Rating
    0
    qi_tronic is on a distinguished road

      0  

    Default [CLOSED]Bug in Element.getXY()

    [CLOSED]Bug in Element.getXY()


    It's actually a 3.3.1 bug but I see the same code unchanged in 4.0 so...

    This code:
    if (el.getBoundingClientRect) {
    b = el.getBoundingClientRect();
    scroll = fly(document).getScroll();
    ret = [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];

    creates some problems if we have an iframe on a page and want to get coordinates for some elements inside it.

    getBoundingClientRect() for an element inside an iframe returns coordinates respective to an iframe's document, not the main document.

    But the code in getXY() always add scroll values of the main document to it.
    So when the main document is scrolled the coordinates inside an iframe get wrong (and are not constant).


    The illustration is here:
    http://www.orfo.ru/online_devel/

    It's actually a modified HTMLEditor coupled with an advanced syntax checking service (sorry the interface is not in English).

    Check the top-right checkbox below editing area for English language, type in any wrong word, press the button on the form footer or the same button in the toolbar for checking.
    Then, when the word get underlined with red, invoke a context menu for that word.

    Before the context menu appears you will see an alert with debugging info.

    Take a note that if you scroll the main document window down before invoking the context menu the word coordinates get the main window scroll added.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,645
    Vote Rating
    583
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    I would say that there are a few methods in the Element class that might not work as you'd expect when using iframes. However at this point I don't see us making any changes to this behaviour, the potential for slowing down a lot of the core lib to check for edge cases like this without a great deal of benefit.

    Thanks for taking the time to write a detailed report.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Similar Threads

  1. Replies: 6
    Last Post: 12 Jan 2010, 3:46 AM
  2. Replies: 1
    Last Post: 13 Dec 2009, 7:10 PM
  3. Replies: 6
    Last Post: 18 Jul 2009, 12:30 PM
  4. position of element "getXY()"
    By everrich in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 9 Oct 2008, 6:50 PM
  5. Replies: 1
    Last Post: 25 Feb 2008, 2:38 PM

Thread Participants: 1