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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/platform/web/scrollcomponent/ScrollEventNormalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

},
get y(): number {
return window.scrollY;
return window.scrollY === undefined ? window.pageYOffset : window.scrollY;
},
},
contentSize: {
Expand Down