Results 1 to 2 of 2

Thread: [CLOSED]Bug in Element.getXY()

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2011
    Moscow, Russia
    Vote Rating

    Default [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( +];

    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:

    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 User evant's Avatar
    Join Date
    Apr 2007
    Sydney, Australia
    Vote Rating


    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.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts