@@ -19,8 +19,6 @@ import {DiscreteEvent, UserBlockingEvent} from 'shared/ReactTypes';
1919
2020type PressListenerProps = { |
2121 onContextMenu : ( e : PressEvent ) => void ,
22- onLongPress : ( e : PressEvent ) => void ,
23- onLongPressChange : boolean => void ,
2422 onPress : ( e : PressEvent ) => void ,
2523 onPressChange : boolean => void ,
2624 onPressEnd : ( e : PressEvent ) => void ,
@@ -30,7 +28,6 @@ type PressListenerProps = {|
3028
3129type PressProps = { |
3230 disabled : boolean ,
33- delayLongPress : number ,
3431 delayPressEnd : number ,
3532 delayPressStart : number ,
3633 pressRetentionOffset : {
@@ -42,8 +39,6 @@ type PressProps = {|
4239 preventContextMenu : boolean ,
4340 preventDefault : boolean ,
4441 stopPropagation : boolean ,
45- enableLongPress : boolean ,
46- longPressShouldCancelPress : ( ) => boolean ,
4742| } ;
4843
4944type PressState = {
@@ -54,10 +49,8 @@ type PressState = {
5449 addedRootEvents : boolean ,
5550 isActivePressed : boolean ,
5651 isActivePressStart : boolean ,
57- isLongPressed : boolean ,
5852 isPressed : boolean ,
5953 isPressWithinResponderRegion : boolean ,
60- longPressTimeout : null | number ,
6154 pointerType : PointerType ,
6255 pressTarget : null | Element | Document ,
6356 pressEndTimeout : null | number ,
@@ -86,8 +79,6 @@ type PressEventType =
8679 | 'pressstart'
8780 | 'pressend'
8881 | 'presschange'
89- | 'longpress'
90- | 'longpresschange'
9182 | 'contextmenu' ;
9283
9384type PressEvent = { |
@@ -117,7 +108,6 @@ const isMac =
117108 : false ;
118109const DEFAULT_PRESS_END_DELAY_MS = 0 ;
119110const DEFAULT_PRESS_START_DELAY_MS = 0 ;
120- const DEFAULT_LONG_PRESS_DELAY_MS = 500 ;
121111const DEFAULT_PRESS_RETENTION_OFFSET = {
122112 bottom : 20 ,
123113 top : 20 ,
@@ -250,14 +240,6 @@ function dispatchPressChangeEvent(
250240 context . dispatchEvent ( 'onPressChange' , bool , DiscreteEvent ) ;
251241}
252242
253- function dispatchLongPressChangeEvent (
254- context : ReactDOMResponderContext ,
255- state : PressState ,
256- ) : void {
257- const bool = state . isLongPressed ;
258- context . dispatchEvent ( 'onLongPressChange' , bool , DiscreteEvent ) ;
259- }
260-
261243function activate ( event : ReactDOMResponderEvent , context , props , state ) {
262244 const nativeEvent : any = event . nativeEvent ;
263245 const { clientX : x , clientY : y } = state . touchEvent || nativeEvent ;
@@ -281,15 +263,10 @@ function activate(event: ReactDOMResponderEvent, context, props, state) {
281263}
282264
283265function deactivate ( event : ?ReactDOMResponderEvent , context , props , state ) {
284- const wasLongPressed = state . isLongPressed ;
285266 state . isActivePressed = false ;
286- state . isLongPressed = false ;
287267
288268 dispatchEvent ( 'onPressEnd' , event , context , state , 'pressend' , DiscreteEvent ) ;
289269 dispatchPressChangeEvent ( context , state ) ;
290- if ( wasLongPressed && props . enableLongPress ) {
291- dispatchLongPressChangeEvent ( context , state ) ;
292- }
293270}
294271
295272function dispatchPressStartEvents (
@@ -308,27 +285,6 @@ function dispatchPressStartEvents(
308285 const dispatch = ( ) => {
309286 state . isActivePressStart = true ;
310287 activate ( event , context , props , state ) ;
311-
312- if ( ! state . isLongPressed && props . enableLongPress ) {
313- const delayLongPress = calculateDelayMS (
314- props . delayLongPress ,
315- 10 ,
316- DEFAULT_LONG_PRESS_DELAY_MS ,
317- ) ;
318- state . longPressTimeout = context . setTimeout ( ( ) => {
319- state . isLongPressed = true ;
320- state . longPressTimeout = null ;
321- dispatchEvent (
322- 'onLongPress' ,
323- event ,
324- context ,
325- state ,
326- 'longpress' ,
327- DiscreteEvent ,
328- ) ;
329- dispatchLongPressChangeEvent ( context , state ) ;
330- } , delayLongPress ) ;
331- }
332288 } ;
333289
334290 if ( ! state . isActivePressStart ) {
@@ -360,11 +316,6 @@ function dispatchPressEndEvents(
360316 state . isActivePressStart = false ;
361317 state . isPressed = false ;
362318
363- if ( state . longPressTimeout !== null ) {
364- context . clearTimeout ( state . longPressTimeout ) ;
365- state . longPressTimeout = null ;
366- }
367-
368319 if ( ! wasActivePressStart && state . pressStartTimeout !== null ) {
369320 context . clearTimeout ( state . pressStartTimeout ) ;
370321 state . pressStartTimeout = null ;
@@ -596,10 +547,8 @@ const pressResponderImpl = {
596547 addedRootEvents : false ,
597548 isActivePressed : false ,
598549 isActivePressStart : false ,
599- isLongPressed : false ,
600550 isPressed : false ,
601551 isPressWithinResponderRegion : true ,
602- longPressTimeout : null ,
603552 pointerType : '' ,
604553 pressEndTimeout : null ,
605554 pressStartTimeout : null ,
@@ -823,19 +772,6 @@ const pressResponderImpl = {
823772 'pressmove' ,
824773 UserBlockingEvent ,
825774 ) ;
826- if (
827- state . activationPosition != null &&
828- state . longPressTimeout != null
829- ) {
830- const deltaX = state . activationPosition . x - nativeEvent . clientX ;
831- const deltaY = state . activationPosition . y - nativeEvent . clientY ;
832- if (
833- Math . hypot ( deltaX , deltaY ) > 10 &&
834- state . longPressTimeout != null
835- ) {
836- context . clearTimeout ( state . longPressTimeout ) ;
837- }
838- }
839775 } else {
840776 dispatchPressStartEvents ( event , context , props , state ) ;
841777 }
@@ -900,7 +836,6 @@ const pressResponderImpl = {
900836 }
901837 }
902838
903- const wasLongPressed = state . isLongPressed ;
904839 const pressTarget = state . pressTarget ;
905840 dispatchPressEndEvents ( event , context , props , state ) ;
906841
@@ -928,23 +863,14 @@ const pressResponderImpl = {
928863 }
929864 }
930865 if ( state . isPressWithinResponderRegion && button !== 1 ) {
931- if (
932- ! (
933- wasLongPressed &&
934- props . enableLongPress &&
935- props . longPressShouldCancelPress &&
936- props . longPressShouldCancelPress ( )
937- )
938- ) {
939- dispatchEvent (
940- 'onPress' ,
941- event ,
942- context ,
943- state ,
944- 'press' ,
945- DiscreteEvent ,
946- ) ;
947- }
866+ dispatchEvent (
867+ 'onPress' ,
868+ event ,
869+ context ,
870+ state ,
871+ 'press' ,
872+ DiscreteEvent ,
873+ ) ;
948874 }
949875 }
950876 state . touchEvent = null ;
0 commit comments