File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change
1
+ import { now } from '../../shared/utils.mjs' ;
2
+
1
3
export default function onClick ( e ) {
2
4
const swiper = this ;
5
+ const data = swiper . touchEventsData ;
6
+
3
7
if ( ! swiper . enabled ) return ;
4
8
if ( ! swiper . allowClick ) {
5
9
if ( swiper . params . preventClicks ) e . preventDefault ( ) ;
6
10
if ( swiper . params . preventClicksPropagation && swiper . animating ) {
7
11
e . stopPropagation ( ) ;
8
12
e . stopImmediatePropagation ( ) ;
9
13
}
14
+ return ;
10
15
}
16
+
17
+ const clickTime = now ( ) ;
18
+ const pathTree = e . path || e . composedPath ?. ( ) ;
19
+
20
+ swiper . updateClickedSlide ( ( pathTree && pathTree [ 0 ] ) || e . target , pathTree ) ;
21
+ swiper . emit ( 'tap click' , e ) ;
22
+
23
+ if ( clickTime - data . lastClickTime < 300 ) {
24
+ swiper . emit ( 'doubleTap doubleClick' , e ) ;
25
+ }
26
+
27
+ data . lastClickTime = now ( ) ;
11
28
}
Original file line number Diff line number Diff line change 1
- import { now , nextTick } from '../../shared/utils.mjs' ;
1
+ import { nextTick } from '../../shared/utils.mjs' ;
2
2
3
3
export default function onTouchEnd ( event ) {
4
4
const swiper = this ;
@@ -55,21 +55,6 @@ export default function onTouchEnd(event) {
55
55
swiper . setGrabCursor ( false ) ;
56
56
}
57
57
58
- // Time diff
59
- const touchEndTime = now ( ) ;
60
- const timeDiff = touchEndTime - data . touchStartTime ;
61
-
62
- // Tap, doubleTap, Click
63
- if ( swiper . allowClick ) {
64
- const pathTree = e . path || ( e . composedPath && e . composedPath ( ) ) ;
65
- swiper . updateClickedSlide ( ( pathTree && pathTree [ 0 ] ) || e . target , pathTree ) ;
66
- swiper . emit ( 'tap click' , e ) ;
67
- if ( timeDiff < 300 && touchEndTime - data . lastClickTime < 300 ) {
68
- swiper . emit ( 'doubleTap doubleClick' , e ) ;
69
- }
70
- }
71
-
72
- data . lastClickTime = now ( ) ;
73
58
nextTick ( ( ) => {
74
59
if ( ! swiper . destroyed ) swiper . allowClick = true ;
75
60
} ) ;
You can’t perform that action at this time.
0 commit comments