-
Notifications
You must be signed in to change notification settings - Fork 48.4k
Disable ViewportMetrics unless MouseEvent lacks support for pageX/pageY #2271
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
Conversation
if (!isMonitoringScrollValue) { | ||
if (hasEventPageXY === undefined) { | ||
hasEventPageXY = | ||
document.createEvent && 'pageX' in document.createEvent('MouseEvent'); |
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.
I think @petehunt's plan was that we'd only access the DOM in files in src/browser/ui/ – but maybe ReactBrowserEventEmitter should be moved there?
This seems pretty reasonable, though I know there's some internal FB code that uses ViewportMetrics that will need to be changed if we do this. |
What if we instead of detecting modern browsers we used a feature flag? It seems kinda niche, unless you are doing stuff with scrolling/long lists. |
@syranide This seems good – mind rebasing? |
For #1300, only IE8 lacks
pageX
/pageY
(and perhaps really old FF or w/e I guess).From my #1300 (comment):
https://github.com/facebook/react/blob/master/src/browser/ui/ReactEventListener.js#L65
https://github.com/facebook/react/blob/master/src/browser/ui/ReactEventListener.js#L165
That makes no sense at all to me,
refresh
does not take an argument, yet we get the scroll position and provide it as an argument. Instead,refresh
gets the scroll position internally and uses that? So we callgetUnboundedScrollPosition
twice, but only use the result once (also, this should be broken for events inside iframes, for IE8).https://github.com/facebook/react/blob/master/src/browser/eventPlugins/TapEventPlugin.js#L54
I'm pretty sure any browsers that supports touch also supports
pageX
/pageY
... ?