@@ -23,10 +23,8 @@ import {getCurrentGestureOffset, stopViewTransition} from './ReactFiberConfig';
2323export type ScheduledGesture = {
2424 provider : GestureTimeline ,
2525 count : number , // The number of times this same provider has been started.
26- direction : boolean , // false = previous, true = next
27- rangePrevious : number , // The end along the timeline where the previous state is reached.
28- rangeCurrent : number , // The starting offset along the timeline.
29- rangeNext : number , // The end along the timeline where the next state is reached.
26+ rangeStart : number , // The percentage along the timeline where the "current" state starts.
27+ rangeEnd : number , // The percentage along the timeline where the "destination" state is reached.
3028 running : null | RunningViewTransition , // Used to cancel the running transition after we're done.
3129 prev : null | ScheduledGesture , // The previous scheduled gesture in the queue for this root.
3230 next : null | ScheduledGesture , // The next scheduled gesture in the queue for this root.
@@ -51,10 +49,8 @@ export function scheduleGesture(
5149 const gesture : ScheduledGesture = {
5250 provider : provider ,
5351 count : 0 ,
54- direction : false ,
55- rangePrevious : - 1 ,
56- rangeCurrent : - 1 ,
57- rangeNext : - 1 ,
52+ rangeStart : 0 , // Uninitialized
53+ rangeEnd : 100 , // Uninitialized
5854 running : null ,
5955 prev : prev ,
6056 next : null ,
@@ -73,45 +69,24 @@ export function startScheduledGesture(
7369 gestureTimeline : GestureTimeline ,
7470 gestureOptions : ?GestureOptions ,
7571) : null | ScheduledGesture {
76- const currentOffset = getCurrentGestureOffset ( gestureTimeline ) ;
77- const range = gestureOptions && gestureOptions . range ;
78- const rangePrevious : number = range ? range [ 0 ] : 0 ; // If no range is provider we assume it's the starting point of the range.
79- const rangeCurrent : number = range ? range [ 1 ] : currentOffset ;
80- const rangeNext : number = range ? range [ 2 ] : 100 ; // If no range is provider we assume it's the starting point of the range.
81- if ( __DEV__ ) {
82- if (
83- ( rangePrevious > rangeCurrent && rangeNext > rangeCurrent ) ||
84- ( rangePrevious < rangeCurrent && rangeNext < rangeCurrent )
85- ) {
86- console . error (
87- 'The range of a gesture needs "previous" and "next" to be on either side of ' +
88- 'the "current" offset. Both cannot be above current and both cannot be below current.' ,
89- ) ;
90- }
91- }
92- const isFlippedDirection = rangePrevious > rangeNext ;
93- const initialDirection =
94- // If a range is specified we can imply initial direction if it's not the current
95- // value such as if the gesture starts after it has already moved.
96- currentOffset < rangeCurrent
97- ? isFlippedDirection
98- : currentOffset > rangeCurrent
99- ? ! isFlippedDirection
100- : // Otherwise, look for an explicit option.
101- gestureOptions
102- ? gestureOptions . direction === 'next'
103- : false ;
104-
72+ const rangeStart =
73+ gestureOptions && gestureOptions . rangeStart != null
74+ ? gestureOptions . rangeStart
75+ : getCurrentGestureOffset ( gestureTimeline ) ;
76+ const rangeEnd =
77+ gestureOptions && gestureOptions . rangeEnd != null
78+ ? gestureOptions . rangeEnd
79+ : rangeStart < 50
80+ ? 100
81+ : 0 ;
10582 let prev = root . pendingGestures ;
10683 while ( prev !== null ) {
10784 if ( prev . provider === gestureTimeline ) {
10885 // Existing instance found.
10986 prev . count ++ ;
11087 // Update the options.
111- prev . direction = initialDirection ;
112- prev . rangePrevious = rangePrevious ;
113- prev . rangeCurrent = rangeCurrent ;
114- prev . rangeNext = rangeNext ;
88+ prev . rangeStart = rangeStart ;
89+ prev . rangeEnd = rangeEnd ;
11590 return prev ;
11691 }
11792 const next = prev . next ;
0 commit comments