@@ -350,23 +350,26 @@ function isActivePointer(
350
350
}
351
351
}
352
352
353
- function isAuxiliary ( buttons : number , nativeEvent : any ) : boolean {
353
+ function isAuxiliary ( buttons : number , event : ReactDOMResponderEvent ) : boolean {
354
+ const nativeEvent : any = event . nativeEvent ;
355
+ const isPrimaryPointer =
356
+ buttons === buttonsEnum . primary || event . pointerType === 'touch' ;
354
357
return (
355
358
// middle-click
356
359
buttons === buttonsEnum . auxiliary ||
357
360
// open-in-new-tab
358
- ( buttons === buttonsEnum . primary && nativeEvent . metaKey ) ||
361
+ ( isPrimaryPointer && nativeEvent . metaKey ) ||
359
362
// open-in-new-window
360
- ( buttons === buttonsEnum . primary && nativeEvent . shiftKey )
363
+ ( isPrimaryPointer && nativeEvent . shiftKey )
361
364
) ;
362
365
}
363
366
364
367
function shouldActivate ( event : ReactDOMResponderEvent ) : boolean {
365
368
const nativeEvent : any = event . nativeEvent ;
366
- const pointerType = event . pointerType ;
367
- const buttons = nativeEvent . buttons ;
368
- const isValidButton = buttons === buttonsEnum . primary ;
369
- return pointerType === 'touch' || ( isValidButton && ! hasModifierKey ( event ) ) ;
369
+ const isPrimaryPointer =
370
+ nativeEvent . buttons === buttonsEnum . primary ||
371
+ event . pointerType === 'touch' ;
372
+ return isPrimaryPointer && ! hasModifierKey ( event ) ;
370
373
}
371
374
372
375
/**
@@ -514,10 +517,7 @@ const responderImpl = {
514
517
515
518
if ( ! state . isActive ) {
516
519
const activate = shouldActivate ( event ) ;
517
- const activateAuxiliary = isAuxiliary (
518
- nativeEvent . buttons ,
519
- nativeEvent ,
520
- ) ;
520
+ const activateAuxiliary = isAuxiliary ( nativeEvent . buttons , event ) ;
521
521
522
522
if ( activate || activateAuxiliary ) {
523
523
state . buttons = nativeEvent . buttons ;
@@ -531,7 +531,9 @@ const responderImpl = {
531
531
}
532
532
}
533
533
534
- if ( activate ) {
534
+ if ( activateAuxiliary ) {
535
+ state . isAuxiliaryActive = true ;
536
+ } else if ( activate ) {
535
537
const gestureState = createGestureState (
536
538
context ,
537
539
props ,
@@ -544,8 +546,6 @@ const responderImpl = {
544
546
state . initialPosition . x = gestureState . x ;
545
547
state . initialPosition . y = gestureState . y ;
546
548
dispatchStart ( context , props , state ) ;
547
- } else if ( activateAuxiliary ) {
548
- state . isAuxiliaryActive = true ;
549
549
}
550
550
}
551
551
break ;
@@ -611,7 +611,7 @@ const responderImpl = {
611
611
if ( state . isActive && isActivePointer ( event , state ) ) {
612
612
state . gestureState = createGestureState ( context , props , state , event ) ;
613
613
state . isActive = false ;
614
- if ( isAuxiliary ( state . buttons , nativeEvent ) ) {
614
+ if ( isAuxiliary ( state . buttons , event ) ) {
615
615
dispatchCancel ( context , props , state ) ;
616
616
dispatchAuxiliaryTap ( context , props , state ) ;
617
617
// Remove the root events here as no 'click' event is dispatched
@@ -626,7 +626,7 @@ const responderImpl = {
626
626
}
627
627
} else if (
628
628
state . isAuxiliaryActive &&
629
- isAuxiliary ( state . buttons , nativeEvent )
629
+ isAuxiliary ( state . buttons , event )
630
630
) {
631
631
state . isAuxiliaryActive = false ;
632
632
state . gestureState = createGestureState ( context , props , state , event ) ;
0 commit comments