-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support IE11 window scroll offset #272
Conversation
@@ -36,10 +36,10 @@ export class ScrollEventNormalizer { | |||
nativeEvent: { | |||
contentOffset: { | |||
get x(): number { | |||
return window.scrollX; | |||
return window.scrollX === undefined ? window.pageXOffset : window.scrollX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there is guarantee that other field will always be there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good question. I think on supported browsers the answer would be: "yes"
At the moment my personal aim for browser support is modern Chrome, Safari, Firefox and Edge, as well as IE11 which is still supported by Microsoft. Of those, the only browser that still uses the old implementation is IE11 where pageXOffset
will always be available.
I found the following on MDN:
The pageXOffset property is an alias for the scrollX property:
window.pageXOffset == window.scrollX; // always true
For cross-browser compatibility, use window.pageXOffset instead of window.scrollX. Additionally, older versions of Internet Explorer (< 9) do not support either property and must be worked around by checking other non-standard properties. A fully compatible example:
var x = (window.pageXOffset !== undefined)
? window.pageXOffset
: (document.documentElement || document.body.parentNode || document.body).scrollLeft;
I'm not sure we want to go that far though. It depends on your idea for browser support in RLV. Either way, at the moment RLV is just broken in IE11 and the proposed implementation will at least fix that, even if it stays broken in other edge case browers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, pulling in the change for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, IE11 support
Thanks for merging @naqvitalha. Any chance there could be another beta release of v2 with this fix? |
The
window.scrollX
andwindow.scrollY
properties are not supported by IE11. As far as I could tell all that is required to add support is to usewindow.pageX/YOffset
in that case.