@@ -1341,13 +1341,22 @@ function _bindEvents(this: DrawGrid): void {
1341
1341
| null
1342
1342
| undefined = null ;
1343
1343
let longTouchId : NodeJS . Timeout | null = null ;
1344
- let touchStartIntervalId : NodeJS . Timeout | null = null ;
1344
+ let useTouch : { timeoutId ?: NodeJS . Timeout } | null = null ;
1345
+ function useTouchStart ( ) {
1346
+ if ( useTouch ?. timeoutId != null ) clearTimeout ( useTouch . timeoutId ) ;
1347
+ useTouch = { } ;
1348
+ }
1349
+ function useTouchEnd ( ) {
1350
+ if ( useTouch ) {
1351
+ if ( useTouch . timeoutId != null ) clearTimeout ( useTouch . timeoutId ) ;
1352
+ useTouch . timeoutId = setTimeout ( ( ) => {
1353
+ useTouch = null ;
1354
+ } , 350 ) ;
1355
+ }
1356
+ }
1345
1357
handler . on ( element , "touchstart" , ( e ) => {
1346
1358
// Since it is an environment where touch start can be used, it blocks mousemove that occurs after this.
1347
- if ( touchStartIntervalId != null ) clearTimeout ( touchStartIntervalId ) ;
1348
- touchStartIntervalId = setTimeout ( ( ) => {
1349
- touchStartIntervalId = null ;
1350
- } , 350 ) ;
1359
+ useTouchStart ( ) ;
1351
1360
1352
1361
if ( ! doubleTapBefore ) {
1353
1362
doubleTapBefore = getCellEventArgsSet ( e ) . eventArgs ;
@@ -1402,9 +1411,13 @@ function _bindEvents(this: DrawGrid): void {
1402
1411
longTouchId = null ;
1403
1412
}
1404
1413
}
1405
- handler . on ( element , "touchcancel" , cancel ) ;
1414
+ handler . on ( element , "touchcancel" , ( e ) => {
1415
+ cancel ( e ) ;
1416
+ useTouchEnd ( ) ;
1417
+ } ) ;
1406
1418
handler . on ( element , "touchmove" , cancel ) ;
1407
1419
handler . on ( element , "touchend" , ( e ) => {
1420
+ useTouchEnd ( ) ;
1408
1421
if ( longTouchId ) {
1409
1422
clearTimeout ( longTouchId ) ;
1410
1423
grid [ _ ] . cellSelector . select ( e ) ;
@@ -1469,7 +1482,7 @@ function _bindEvents(this: DrawGrid): void {
1469
1482
} ) ;
1470
1483
1471
1484
handler . on ( element , "mousemove" , ( e ) => {
1472
- if ( touchStartIntervalId != null ) {
1485
+ if ( useTouch ) {
1473
1486
// Probably a mousemove event triggered by a touchstart. Therefore, this event is blocked.
1474
1487
return ;
1475
1488
}
0 commit comments