11import { clearSelection } from '../utils/selection.js'
22import { prevent } from '../utils/event.js'
3- import { addEvt , cleanEvt } from '../utils/touch.js'
3+ import { addEvt , cleanEvt , getTouchTarget } from '../utils/touch.js'
44
55export default {
66 props : {
@@ -66,12 +66,19 @@ export default {
6666 }
6767 } ,
6868
69- __mobileTouch ( evt ) {
69+ __mobileCleanup ( evt ) {
70+ this . anchorEl . classList . remove ( 'non-selectable' )
7071 clearTimeout ( this . touchTimer )
7172
7273 if ( this . showing === true && evt !== void 0 ) {
7374 clearSelection ( )
7475 }
76+ } ,
77+
78+ __mobilePrevent : prevent ,
79+
80+ __mobileTouch ( evt ) {
81+ this . __mobileCleanup ( evt )
7582
7683 if ( this . __showCondition ( evt ) !== true ) {
7784 return
@@ -80,9 +87,16 @@ export default {
8087 this . hide ( evt )
8188 this . anchorEl . classList . add ( 'non-selectable' )
8289
90+ const target = getTouchTarget ( evt . target )
91+ addEvt ( this , 'anchor' , [
92+ [ target , 'touchmove' , '__mobileCleanup' , 'passive' ] ,
93+ [ target , 'touchend' , '__mobileCleanup' , 'passive' ] ,
94+ [ target , 'touchcancel' , '__mobileCleanup' , 'passive' ] ,
95+ [ this . anchorEl , 'contextmenu' , '__mobilePrevent' , 'notPassive' ]
96+ ] )
97+
8398 this . touchTimer = setTimeout ( ( ) => {
8499 this . show ( evt )
85- this . anchorEl . classList . remove ( 'non-selectable' )
86100 } , 300 )
87101 } ,
88102
0 commit comments