mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Disable ViewportMetrics unless MouseEvent lacks support for pageX/pageY
This commit is contained in:
committed by
Dan Abramov
parent
13871886ba
commit
471b4af2c8
@@ -74,6 +74,7 @@ var isEventSupported = require('isEventSupported');
|
||||
* React Core . General Purpose Event Plugin System
|
||||
*/
|
||||
|
||||
var hasEventPageXY;
|
||||
var alreadyListeningTo = {};
|
||||
var isMonitoringScrollValue = false;
|
||||
var reactTopListenersCounter = 0;
|
||||
@@ -345,12 +346,19 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
||||
* Listens to window scroll and resize events. We cache scroll values so that
|
||||
* application code can access them without triggering reflows.
|
||||
*
|
||||
* ViewportMetrics is only used by SyntheticMouse/TouchEvent and only when
|
||||
* pageX/pageY isn't supported (legacy browsers).
|
||||
*
|
||||
* NOTE: Scroll events do not bubble.
|
||||
*
|
||||
* @see http://www.quirksmode.org/dom/events/scroll.html
|
||||
*/
|
||||
ensureScrollValueMonitoring: function() {
|
||||
if (!isMonitoringScrollValue) {
|
||||
ensureScrollValueMonitoring: function(){
|
||||
if (hasEventPageXY === undefined) {
|
||||
hasEventPageXY =
|
||||
document.createEvent && 'pageX' in document.createEvent('MouseEvent');
|
||||
}
|
||||
if (!hasEventPageXY && !isMonitoringScrollValue) {
|
||||
var refresh = ViewportMetrics.refreshScrollValues;
|
||||
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
|
||||
isMonitoringScrollValue = true;
|
||||
|
||||
Reference in New Issue
Block a user