@@ -366,6 +366,50 @@ export const Carousel = defineComponent({
366
366
document . removeEventListener ( 'keydown' , handleArrowKeys )
367
367
}
368
368
369
+ const handleScroll = throttle ( ( event : Event ) : void => {
370
+ if ( ! config . mouseScroll || isSliding . value ) {
371
+ return
372
+ }
373
+
374
+ // Prevent default scrolling behavior when wheel navigation is enabled
375
+ event . preventDefault ( )
376
+
377
+ const wheelEvent = event as WheelEvent
378
+
379
+ // Add sensitivity threshold to prevent small movements from triggering navigation
380
+ const threshold = config . mouseScrollThreshold ?? 30 // Default to 30 if undefined
381
+
382
+ // Determine scroll direction
383
+ const deltaY = Math . abs ( wheelEvent . deltaY ) > threshold ? wheelEvent . deltaY : 0
384
+ const deltaX = Math . abs ( wheelEvent . deltaX ) > threshold ? wheelEvent . deltaX : 0
385
+
386
+ // If neither delta exceeds the threshold, don't navigate
387
+ if ( deltaY === 0 && deltaX === 0 ) {
388
+ return
389
+ }
390
+
391
+ const isScrollingDown = deltaY > 0
392
+ const isScrollingRight = deltaX > 0
393
+
394
+ // Determine direction based on carousel orientation and scroll direction
395
+ if (
396
+ ( isVertical . value && isScrollingDown ) ||
397
+ ( ! isVertical . value && isScrollingRight )
398
+ ) {
399
+ if ( isReversed . value ) {
400
+ prev ( )
401
+ } else {
402
+ next ( )
403
+ }
404
+ } else {
405
+ if ( isReversed . value ) {
406
+ next ( )
407
+ } else {
408
+ prev ( )
409
+ }
410
+ }
411
+ } , 150 )
412
+
369
413
/**
370
414
* Autoplay
371
415
*/
@@ -406,6 +450,7 @@ export const Carousel = defineComponent({
406
450
isReversed : isReversed . value ,
407
451
dragged : { x : deltaX , y : deltaY } ,
408
452
effectiveSlideSize : effectiveSlideSize . value ,
453
+ threshold : config . mouseDragThreshold as number ,
409
454
} )
410
455
411
456
activeSlideIndex . value = config . wrapAround
0 commit comments