mirror of
https://github.com/status-im/react-native.git
synced 2025-01-25 00:39:03 +00:00
use performanceNow instead of Date.now() in ScrollResponder
Reviewed By: shergin Differential Revision: D4833701 fbshipit-source-id: cb127cb6c40ecb188100eeb204412401c7772c9e
This commit is contained in:
parent
4f243f1ecd
commit
6dbcb47e4c
@ -25,6 +25,7 @@ var { getInstanceFromNode } = require('ReactNativeComponentTree');
|
||||
var { ScrollViewManager } = require('NativeModules');
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var performanceNow = require('fbjs/lib/performanceNow');
|
||||
|
||||
/**
|
||||
* Mixin that can be integrated in order to handle scrolling that plays well
|
||||
@ -321,7 +322,7 @@ var ScrollResponderMixin = {
|
||||
* Invoke this from an `onMomentumScrollBegin` event.
|
||||
*/
|
||||
scrollResponderHandleMomentumScrollBegin: function(e: Event) {
|
||||
this.state.lastMomentumScrollBeginTime = Date.now();
|
||||
this.state.lastMomentumScrollBeginTime = performanceNow();
|
||||
this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
|
||||
},
|
||||
|
||||
@ -330,7 +331,7 @@ var ScrollResponderMixin = {
|
||||
*/
|
||||
scrollResponderHandleMomentumScrollEnd: function(e: Event) {
|
||||
FrameRateLogger.endScroll();
|
||||
this.state.lastMomentumScrollEndTime = Date.now();
|
||||
this.state.lastMomentumScrollEndTime = performanceNow();
|
||||
this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e);
|
||||
},
|
||||
|
||||
@ -371,7 +372,7 @@ var ScrollResponderMixin = {
|
||||
* a touch has just started or ended.
|
||||
*/
|
||||
scrollResponderIsAnimating: function(): boolean {
|
||||
var now = Date.now();
|
||||
var now = performanceNow();
|
||||
var timeSinceLastMomentumScrollEnd = now - this.state.lastMomentumScrollEndTime;
|
||||
var isAnimating = timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS ||
|
||||
this.state.lastMomentumScrollEndTime < this.state.lastMomentumScrollBeginTime;
|
||||
|
Loading…
x
Reference in New Issue
Block a user