Loading ...
Sorry, an error occurred while loading the content.

dom.getXY returning wrong position on IE?

Expand Messages
  • Andreas Schiffler
    Hi all, util.Dom.getXY operating on a DIV object is returning the wrong corner position on IE ... it is shifted by 2 pixels on IE6 (but fine on Firefox 1.5).
    Message 1 of 4 , Jul 31 2:21 PM
    • 0 Attachment
      Hi all,

      util.Dom.getXY operating on a DIV object is returning the wrong corner
      position on IE ... it is shifted by 2 pixels on IE6 (but fine on Firefox
      1.5). This is using YUI version 0.11.1.

      Here is the pseudo code:
      - create DIV "a" with known size w,h
      - get position of "a" using
      xy=getXY(a)
      - overlay semi-transparent DIV "b" using for the style
      position="absolute"
      left=xy[0]+"px"
      top=xy[1]+"px"
      width=w+"px"
      height=h+"px"


      Any ideas?

      Bye
      Andreas
    • Matt Sweeney
      Hi Andreas, Using Dom.setXY() should fix this: - create DIV a with known size w,h - get position of a using xy=getXY(a) - overlay semi-transparent DIV b
      Message 2 of 4 , Jul 31 3:52 PM
      • 0 Attachment
        Hi Andreas,

        Using Dom.setXY() should fix this:

        - create DIV "a" with known size w,h
        - get position of "a" using
        xy=getXY(a)
        - overlay semi-transparent DIV "b" using for the style
        position="absolute"
        //left=xy[0]+"px"
        //top=xy[1]+"px"
        YAHOO.util.Dom.setXY(b, xy);
        width=w+"px"
        height=h+"px"


        There are some default styles that are inherited which can affect the
        position which this will take into account.

        Matt

        Andreas Schiffler wrote:

        >Hi all,
        >
        >util.Dom.getXY operating on a DIV object is returning the wrong corner
        >position on IE ... it is shifted by 2 pixels on IE6 (but fine on Firefox
        >1.5). This is using YUI version 0.11.1.
        >
        >Here is the pseudo code:
        >- create DIV "a" with known size w,h
        >- get position of "a" using
        > xy=getXY(a)
        >- overlay semi-transparent DIV "b" using for the style
        > position="absolute"
        > left=xy[0]+"px"
        > top=xy[1]+"px"
        > width=w+"px"
        > height=h+"px"
        >
        >
        >Any ideas?
        >
        >Bye
        >Andreas
        >
        >
        >
        >
        >Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
      • msheakoski
        Hello Matt, I ran into this problem as well. The solution you posted seems like a little more work than it should be though. Since getXY() is doing special
        Message 3 of 4 , Oct 18, 2006
        • 0 Attachment
          Hello Matt,

          I ran into this problem as well. The solution you posted seems like a
          little more work than it should be though. Since getXY() is doing
          special routine for IE anyway, why not just account for the
          BoundingClientRect offset automatically?

          Line 207 of dom.js:
          return [box.left - 2 + scrollLeft, box.top - 2 + scrollTop];

          This would account for the 2px difference in IE.

          Thanks,
          -Michael


          --- In ydn-javascript@yahoogroups.com, Matt Sweeney <msweeney@...> wrote:
          >
          > Hi Andreas,
          >
          > Using Dom.setXY() should fix this:
          >
          > - create DIV "a" with known size w,h
          > - get position of "a" using
          > xy=getXY(a)
          > - overlay semi-transparent DIV "b" using for the style
          > position="absolute"
          > //left=xy[0]+"px"
          > //top=xy[1]+"px"
          > YAHOO.util.Dom.setXY(b, xy);
          > width=w+"px"
          > height=h+"px"
          >
          >
          > There are some default styles that are inherited which can affect the
          > position which this will take into account.
          >
          > Matt
          >
          > Andreas Schiffler wrote:
          >
          > >Hi all,
          > >
          > >util.Dom.getXY operating on a DIV object is returning the wrong corner
          > >position on IE ... it is shifted by 2 pixels on IE6 (but fine on
          Firefox
          > >1.5). This is using YUI version 0.11.1.
          > >
          > >Here is the pseudo code:
          > >- create DIV "a" with known size w,h
          > >- get position of "a" using
          > > xy=getXY(a)
          > >- overlay semi-transparent DIV "b" using for the style
          > > position="absolute"
          > > left=xy[0]+"px"
          > > top=xy[1]+"px"
          > > width=w+"px"
          > > height=h+"px"
          > >
          > >
          > >Any ideas?
          > >
          > >Bye
          > >Andreas
          > >
          > >
          > >
          > >
          > >Yahoo! Groups Links
          > >
          > >
          > >
          > >
          > >
          > >
          >
        • msheakoski
          Nevermind I see where I went wrong. Basically if you use getXY() you should also use setXY() instead of setting the top/left styles. If you try to mix getXY
          Message 4 of 4 , Oct 18, 2006
          • 0 Attachment
            Nevermind I see where I went wrong. Basically if you use getXY() you
            should also use setXY() instead of setting the top/left styles. If
            you try to mix getXY with top/left you will get the 2px offset.

            --- In ydn-javascript@yahoogroups.com, "msheakoski" <msheakoski@...>
            wrote:
            >
            > Hello Matt,
            >
            > I ran into this problem as well. The solution you posted seems like a
            > little more work than it should be though. Since getXY() is doing
            > special routine for IE anyway, why not just account for the
            > BoundingClientRect offset automatically?
            >
            > Line 207 of dom.js:
            > return [box.left - 2 + scrollLeft, box.top - 2 + scrollTop];
            >
            > This would account for the 2px difference in IE.
            >
            > Thanks,
            > -Michael
            >
            >
            > --- In ydn-javascript@yahoogroups.com, Matt Sweeney <msweeney@> wrote:
            > >
            > > Hi Andreas,
            > >
            > > Using Dom.setXY() should fix this:
            > >
            > > - create DIV "a" with known size w,h
            > > - get position of "a" using
            > > xy=getXY(a)
            > > - overlay semi-transparent DIV "b" using for the style
            > > position="absolute"
            > > //left=xy[0]+"px"
            > > //top=xy[1]+"px"
            > > YAHOO.util.Dom.setXY(b, xy);
            > > width=w+"px"
            > > height=h+"px"
            > >
            > >
            > > There are some default styles that are inherited which can affect the
            > > position which this will take into account.
            > >
            > > Matt
            > >
            > > Andreas Schiffler wrote:
            > >
            > > >Hi all,
            > > >
            > > >util.Dom.getXY operating on a DIV object is returning the wrong
            corner
            > > >position on IE ... it is shifted by 2 pixels on IE6 (but fine on
            > Firefox
            > > >1.5). This is using YUI version 0.11.1.
            > > >
            > > >Here is the pseudo code:
            > > >- create DIV "a" with known size w,h
            > > >- get position of "a" using
            > > > xy=getXY(a)
            > > >- overlay semi-transparent DIV "b" using for the style
            > > > position="absolute"
            > > > left=xy[0]+"px"
            > > > top=xy[1]+"px"
            > > > width=w+"px"
            > > > height=h+"px"
            > > >
            > > >
            > > >Any ideas?
            > > >
            > > >Bye
            > > >Andreas
            > > >
            > > >
            > > >
            > > >
            > > >Yahoo! Groups Links
            > > >
            > > >
            > > >
            > > >
            > > >
            > > >
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.