File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export class CcSwiper extends ChuciElement {
1313 private divPagination ?: HTMLDivElement
1414 private divPrevious ?: HTMLDivElement
1515 private divNext ?: HTMLDivElement
16+ private isDragging = false
1617
1718 static get observedAttributes ( ) {
1819 return [ 'has-thumb' , 'autoplay' ]
@@ -282,6 +283,12 @@ export class CcSwiper extends ChuciElement {
282283 img . addEventListener ( 'dragstart' , ( e ) => e . preventDefault ( ) )
283284
284285 img . addEventListener ( 'click' , ( e ) => {
286+ // Ignore click if user was dragging
287+ if ( this . isDragging ) {
288+ this . isDragging = false
289+ return
290+ }
291+
285292 e . preventDefault ( )
286293 e . stopPropagation ( )
287294 e . stopImmediatePropagation ( )
@@ -346,7 +353,18 @@ export class CcSwiper extends ChuciElement {
346353 preventClicksPropagation : false ,
347354 simulateTouch : true ,
348355 allowTouchMove : true ,
349- loop : slidesLoop
356+ loop : slidesLoop ,
357+ on : {
358+ sliderMove : ( ) => {
359+ this . isDragging = true
360+ } ,
361+ touchEnd : ( ) => {
362+ // Reset dragging flag after a short delay to allow click event to check it
363+ setTimeout ( ( ) => {
364+ this . isDragging = false
365+ } , 50 )
366+ }
367+ }
350368 } )
351369 }
352370}
You can’t perform that action at this time.
0 commit comments