React-router: scrollPosition broken in IE11 -- pageYOffset fixes

Created on 13 Dec 2014  ·  3Comments  ·  Source: ReactTraining/react-router

...window.scrollX and scrollY return undefined there.

Mozilla docs say "For cross-browser compatibility, use window.pageYOffset instead of window.scrollY.".

They also have a patch for IE's below 9, if you care :)

Most helpful comment

React does it like this:

    return {
      x: window.pageXOffset || document.documentElement.scrollLeft,
      y: window.pageYOffset || document.documentElement.scrollTop
    };

We should probably do the same! Would you like to make a PR?

All 3 comments

React does it like this:

    return {
      x: window.pageXOffset || document.documentElement.scrollLeft,
      y: window.pageYOffset || document.documentElement.scrollTop
    };

We should probably do the same! Would you like to make a PR?

Sure, sounds good! Do you think a test makes sense? Seems like most tests were pure logic, not DOM.

I don't know @rpflorence's stance on this but since it's a one-off thing, not related to logic and React already has a “reference implementation”, IMO fixing it and adding a link to relevant React source code piece should be enough. Can't be sure though!

Was this page helpful?
0 / 5 - 0 ratings