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+
13export default function onClick ( e ) {
24 const swiper = this ;
5+ const data = swiper . touchEventsData ;
6+
37 if ( ! swiper . enabled ) return ;
48 if ( ! swiper . allowClick ) {
59 if ( swiper . params . preventClicks ) e . preventDefault ( ) ;
610 if ( swiper . params . preventClicksPropagation && swiper . animating ) {
711 e . stopPropagation ( ) ;
812 e . stopImmediatePropagation ( ) ;
913 }
14+ return ;
1015 }
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 ( ) ;
1128}
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' ;
22
33export default function onTouchEnd ( event ) {
44 const swiper = this ;
@@ -55,21 +55,6 @@ export default function onTouchEnd(event) {
5555 swiper . setGrabCursor ( false ) ;
5656 }
5757
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 ( ) ;
7358 nextTick ( ( ) => {
7459 if ( ! swiper . destroyed ) swiper . allowClick = true ;
7560 } ) ;
You can’t perform that action at this time.
0 commit comments