@@ -149,6 +149,8 @@ class TouchSelectionMenuController {
149149 #selectionActive = false ;
150150 #menuActive = false ;
151151 #enabled = true ;
152+ #touchListenersAttached = false ;
153+ #touchMovePassive = true ;
152154 #handlingMenuAction = false ;
153155 #pendingPointerTriggered = false ;
154156 #pendingSelectionChanged = false ;
@@ -494,7 +496,7 @@ class TouchSelectionMenuController {
494496 longPressFired : false ,
495497 } ;
496498
497- this . #addTouchListeners( ) ;
499+ this . #addTouchListeners( { passiveMove : true } ) ;
498500 this . #clearLongPress( ) ;
499501 this . #longPressTimer = setTimeout ( ( ) => {
500502 if ( ! this . #touchSession || this . #touchSession. moved ) return ;
@@ -627,18 +629,32 @@ class TouchSelectionMenuController {
627629 this . #showCursorHandle( ) ;
628630 } ;
629631
630- #addTouchListeners( ) {
632+ #addTouchListeners( { passiveMove = true } = { } ) {
633+ if (
634+ this . #touchListenersAttached &&
635+ this . #touchMovePassive === passiveMove
636+ ) {
637+ return ;
638+ }
639+ if ( this . #touchListenersAttached) {
640+ this . #removeTouchListeners( ) ;
641+ }
642+ this . #touchMovePassive = passiveMove ;
631643 document . addEventListener ( "touchmove" , this . #onTouchMove, {
632- passive : false ,
644+ passive : passiveMove ,
633645 } ) ;
634646 document . addEventListener ( "touchend" , this . #onTouchEnd, {
635647 passive : false ,
636648 } ) ;
649+ this . #touchListenersAttached = true ;
637650 }
638651
639652 #removeTouchListeners( ) {
653+ if ( ! this . #touchListenersAttached) return ;
640654 document . removeEventListener ( "touchmove" , this . #onTouchMove) ;
641655 document . removeEventListener ( "touchend" , this . #onTouchEnd) ;
656+ this . #touchListenersAttached = false ;
657+ this . #touchMovePassive = true ;
642658 }
643659
644660 #clearLongPress( ) {
@@ -1047,7 +1063,7 @@ class TouchSelectionMenuController {
10471063 } ;
10481064 this . #pointer. x = x ;
10491065 this . #pointer. y = y ;
1050- this . #addTouchListeners( ) ;
1066+ this . #addTouchListeners( { passiveMove : false } ) ;
10511067 }
10521068
10531069 #dragTo( x , y ) {
0 commit comments