janpaul123 / delayed-scroll-restoration-polyfill

Polyfill that mimics Chrome's scroll restoration behavior.
Other
105 stars 8 forks source link

IE11 Compatibility #3

Open jmaikeru opened 7 years ago

jmaikeru commented 7 years ago

Transpiled this to EC5- works just fine aside from needing a polyfill for Number.isFinite- also needed to change the scrollX/Y properties to pageOffsetX/Y- similar to https://github.com/ReactTraining/react-router/issues/605

Should I submit a pull request?

trotzig commented 7 years ago

You mean ES5, right? The shipped npm module is already transpiled, but you're right that we need the polyfill and the x/y properties.

We'd be very happy for a PR!

jmaikeru commented 7 years ago

Ah, yes, turns out I can't type. I grabbed the raw .js from Github instead of installing the node module.

Will cook something up- what would your preferred approach be to dealing with Number.isFinite?

Could either:

  1. Include the polyfill, or
  2. Use the function locally, or
  3. Update docs and call it a dependency for IE11
trotzig commented 7 years ago

I think we should just switch to isFinite. It doesn't check that the argument is a number, but it works across all browsers. And we know that we're always passing in numbers.

kallebornemark commented 5 years ago

So, is this compatible with IE11?

jmaikeru commented 5 years ago

Yes and no.

Change lines 11-12 in index.es6.js to:

      __scrollX: window.pageXOffset || document.documentElement.scrollLeft,
      __scrollY: window.pageYOffset || document.documentElement.scrollTop,

and 66-67 in the same file to:

        isFinite(state.__scrollX) &&
        isFinite(state.__scrollY)) {

Those are IE11 compatible.

I never did submit a PR 😬

kallebornemark commented 5 years ago

Thank you @jmaikeru!

juliaqiuxy commented 4 years ago

Created a PR https://github.com/janpaul123/delayed-scroll-restoration-polyfill/pull/9

Thanks, @jmaikeru!