Skip to content

Commit da6cf79

Browse files
The dragMinThreshold accepts an object for a mouse threshold.
1 parent 56ca26d commit da6cf79

File tree

17 files changed

+70
-46
lines changed

17 files changed

+70
-46
lines changed

dist/js/splide-renderer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.cjs.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Splide.js
3-
* Version : 3.1.0
3+
* Version : 3.1.1
44
* License : MIT
55
* Copyright: 2021 Naotoshi Fujita
66
*/
@@ -1776,7 +1776,6 @@ function Drag(Splide2, Components2, options) {
17761776
}
17771777
function onPointerMove(e) {
17781778
if (!lastEvent) {
1779-
clickPrevented = true;
17801779
emit(EVENT_DRAG);
17811780
}
17821781
lastEvent = e;
@@ -1789,10 +1788,13 @@ function Drag(Splide2, Components2, options) {
17891788
}
17901789
Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
17911790
emit(EVENT_DRAGGING);
1791+
clickPrevented = true;
17921792
prevent(e);
17931793
} else {
1794-
const threshold = options.dragMinThreshold || 10;
1795-
isDragging = !isTouchEvent(e) || abs(coordOf(e) - coordOf(baseEvent)) > threshold;
1794+
const diff = abs(coordOf(e) - coordOf(baseEvent));
1795+
let { dragMinThreshold: thresholds } = options;
1796+
thresholds = isObject(thresholds) ? thresholds : { mouse: 0, touch: +thresholds || 10 };
1797+
isDragging = diff > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
17961798
if (isSliderDirection()) {
17971799
prevent(e);
17981800
}

dist/js/splide.esm.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Splide.js
3-
* Version : 3.1.0
3+
* Version : 3.1.1
44
* License : MIT
55
* Copyright: 2021 Naotoshi Fujita
66
*/
@@ -1772,7 +1772,6 @@ function Drag(Splide2, Components2, options) {
17721772
}
17731773
function onPointerMove(e) {
17741774
if (!lastEvent) {
1775-
clickPrevented = true;
17761775
emit(EVENT_DRAG);
17771776
}
17781777
lastEvent = e;
@@ -1785,10 +1784,13 @@ function Drag(Splide2, Components2, options) {
17851784
}
17861785
Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
17871786
emit(EVENT_DRAGGING);
1787+
clickPrevented = true;
17881788
prevent(e);
17891789
} else {
1790-
const threshold = options.dragMinThreshold || 10;
1791-
isDragging = !isTouchEvent(e) || abs(coordOf(e) - coordOf(baseEvent)) > threshold;
1790+
const diff = abs(coordOf(e) - coordOf(baseEvent));
1791+
let { dragMinThreshold: thresholds } = options;
1792+
thresholds = isObject(thresholds) ? thresholds : { mouse: 0, touch: +thresholds || 10 };
1793+
isDragging = diff > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
17921794
if (isSliderDirection()) {
17931795
prevent(e);
17941796
}

dist/js/splide.js

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js.gz

27 Bytes
Binary file not shown.

dist/types/components/Drag/Drag.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/components/Scroll/Scroll.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/types/options.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,12 @@ export interface ResponsiveOptions {
273273
drag?: boolean | 'free';
274274
/**
275275
* The required distance to start moving the slider by the touch action.
276-
* Other pointing devices will ignore this value.
276+
* If you want to define the threshold for the mouse, provide an object.
277277
*/
278-
dragMinThreshold?: number;
278+
dragMinThreshold?: number | {
279+
mouse: number;
280+
touch: number;
281+
};
279282
/**
280283
* Determine the power of "flick". The larger number this is, the farther the slider runs.
281284
* Around 500 is recommended.

0 commit comments

Comments
 (0)