Skip to content
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

Merged
merged 1 commit into from
Nov 19, 2018
Merged

Conversation

marnusw
Copy link
Contributor

@marnusw marnusw commented Nov 5, 2018

The window.scrollX and window.scrollY properties are not supported by IE11. As far as I could tell all that is required to add support is to use window.pageX/YOffset in that case.

@@ -36,10 +36,10 @@ export class ScrollEventNormalizer {
nativeEvent: {
contentOffset: {
get x(): number {
return window.scrollX;
return window.scrollX === undefined ? window.pageXOffset : window.scrollX;
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@naqvitalha naqvitalha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, IE11 support

@naqvitalha naqvitalha merged commit 8535de7 into Flipkart:master Nov 19, 2018
@marnusw marnusw deleted the ie11Scroll branch November 19, 2018 10:45
@marnusw
Copy link
Contributor Author

marnusw commented Nov 20, 2018

Thanks for merging @naqvitalha. Any chance there could be another beta release of v2 with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants