Skip to content

Commit ab25fad

Browse files
committed
noUiSlider 15.6.0
1 parent 8f1a169 commit ab25fad

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

dist/nouislider.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@
714714
var hover = entry.indexOf("hover") >= 0;
715715
var unconstrained = entry.indexOf("unconstrained") >= 0;
716716
var dragAll = entry.indexOf("drag-all") >= 0;
717+
var smoothSteps = entry.indexOf("smooth-steps") >= 0;
717718
if (fixed) {
718719
if (parsed.handles !== 2) {
719720
throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");
@@ -728,6 +729,7 @@
728729
tap: tap || snap,
729730
drag: drag,
730731
dragAll: dragAll,
732+
smoothSteps: smoothSteps,
731733
fixed: fixed,
732734
snap: snap,
733735
hover: hover,
@@ -1472,6 +1474,14 @@
14721474
scope_Body.removeEventListener("selectstart", preventDefault);
14731475
}
14741476
}
1477+
if (options.events.smoothSteps) {
1478+
data.handleNumbers.forEach(function (handleNumber) {
1479+
setHandle(handleNumber, scope_Locations[handleNumber], true, true, false, false);
1480+
});
1481+
data.handleNumbers.forEach(function (handleNumber) {
1482+
fireEvent("update", handleNumber);
1483+
});
1484+
}
14751485
data.handleNumbers.forEach(function (handleNumber) {
14761486
fireEvent("change", handleNumber);
14771487
fireEvent("set", handleNumber);
@@ -1771,7 +1781,7 @@
17711781
});
17721782
}
17731783
// Split out the handle positioning logic so the Move event can use it, too
1774-
function checkHandlePosition(reference, handleNumber, to, lookBackward, lookForward, getValue) {
1784+
function checkHandlePosition(reference, handleNumber, to, lookBackward, lookForward, getValue, smoothSteps) {
17751785
var distance;
17761786
// For sliders with multiple handles, limit movement to the other handle.
17771787
// Apply the margin option by adding it to the handle positions.
@@ -1810,7 +1820,9 @@
18101820
to = Math.min(to, distance);
18111821
}
18121822
}
1813-
to = scope_Spectrum.getStep(to);
1823+
if (!smoothSteps) {
1824+
to = scope_Spectrum.getStep(to);
1825+
}
18141826
// Limit percentage to the 0 - 100 range
18151827
to = limit(to);
18161828
// Return false if handle can't move
@@ -1830,6 +1842,7 @@
18301842
var proposals = locations.slice();
18311843
// Store first handle now, so we still have it in case handleNumbers is reversed
18321844
var firstHandle = handleNumbers[0];
1845+
var smoothSteps = options.events.smoothSteps;
18331846
var b = [!upward, upward];
18341847
var f = [upward, !upward];
18351848
// Copy handleNumbers so we don't change the dataset
@@ -1842,7 +1855,7 @@
18421855
// Step 1: get the maximum percentage that any of the handles can move
18431856
if (handleNumbers.length > 1) {
18441857
handleNumbers.forEach(function (handleNumber, o) {
1845-
var to = checkHandlePosition(proposals, handleNumber, proposals[handleNumber] + proposal, b[o], f[o], false);
1858+
var to = checkHandlePosition(proposals, handleNumber, proposals[handleNumber] + proposal, b[o], f[o], false, smoothSteps);
18461859
// Stop if one of the handles can't move.
18471860
if (to === false) {
18481861
proposal = 0;
@@ -1860,7 +1873,8 @@
18601873
var state = false;
18611874
// Step 2: Try to set the handles with the found percentage
18621875
handleNumbers.forEach(function (handleNumber, o) {
1863-
state = setHandle(handleNumber, locations[handleNumber] + proposal, b[o], f[o]) || state;
1876+
state =
1877+
setHandle(handleNumber, locations[handleNumber] + proposal, b[o], f[o], false, smoothSteps) || state;
18641878
});
18651879
// Step 3: If a handle moved, fire events
18661880
if (state) {
@@ -1905,9 +1919,9 @@
19051919
}
19061920
// Test suggested values and apply margin, step.
19071921
// if exactInput is true, don't run checkHandlePosition, then the handle can be placed in between steps (#436)
1908-
function setHandle(handleNumber, to, lookBackward, lookForward, exactInput) {
1922+
function setHandle(handleNumber, to, lookBackward, lookForward, exactInput, smoothSteps) {
19091923
if (!exactInput) {
1910-
to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false);
1924+
to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false, smoothSteps);
19111925
}
19121926
if (to === false) {
19131927
return false;

0 commit comments

Comments
 (0)