-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
React tracks scroll position internally and forces synchronous layout #1300
Comments
ViewportMetrics is used to normalize pageX and pageY on mouse events: SyntheticMouseEvent.js#L63-L73. Perhaps ironically, it was created to prevent synchronous layouts during mouse event handlers. |
I wish these values (as well as the event) were somehow exposed. |
👍 |
BTW you can obviously have this if you use a Webpack-like bundler: // get_scroll_y.js
'use strict';
var ReactBrowserEventEmitter = require('react/lib/ReactBrowserEventEmitter'),
ViewportMetrics = require('react/lib/ViewportMetrics');
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
ViewportMetrics.refreshScrollValues();
function getScrollY() {
return ViewportMetrics.currentScrollTop;
}
module.exports = getScrollY; |
Well, Also, That makes no sense at all to me, Also2, cc @spicyj |
I agree that we shouldn't be tracking it in other browsers if we don't need it. I don't know if there's a way to predict whether we'll have .pageX and .pageY before mouse events actually come in. |
@spicyj |
Another idea being just let resize/scroll set a flag, when a mouse event is created, if the flag is set, update viewport metrics. That way we only update it when needed, but could potentially cause a reflow if there are other events before it (very unlikely though I imagine). |
This issue causes React based longer lists unusable on mobile. |
Is there any progress on this issue? I’m not sure if this is the root-cause for pages rendered with react scrolling extremely slow with firefox mobile on android (e.g. this react website http://isomorphic500.herokuapp.com/featured/highest_rated). |
@spicyj No, that is not my site, it is an example react & fluxible page (see: https://github.com/gpbl/isomorphic500), but we have exactly the same issues with scrolling on firefox mobile. |
React adds a scroll listener that tracks and caches the scroll position (I assume for some undocumented internal purpose). Additionally, the scroll listener forces a synchronous layout (see screenshot). This seems wasteful, especially considering that the values tracked are never exposed in the API.
What is the scroll listener used for? Can it be removed?
The text was updated successfully, but these errors were encountered: