Skip to content

Commit

Permalink
noUiSlider 14.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed Sep 16, 2020
1 parent 0e80da6 commit 5e026db
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 14.6.2 (*2020-09-16*)
- Fixed: Ignore erroneous mouse events on taps for iOS 13.4 (#1095);
- Added: `exactInput` argument to `set` and `setHandle` methods (#436, #1094);

### 14.6.1 (*2020-08-17*)
- Fixed: Pips in count mode ignores pip at end of range (#1088);

Expand Down
2 changes: 1 addition & 1 deletion distribute/nouislider.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! nouislider - 14.6.1 - 8/17/2020 */
/*! nouislider - 14.6.2 - 9/16/2020 */
/* Functional styling;
* These styles are required for noUiSlider to function.
* You don't need to change these rules to apply your design.
Expand Down
36 changes: 20 additions & 16 deletions distribute/nouislider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! nouislider - 14.6.1 - 8/17/2020 */
/*! nouislider - 14.6.2 - 9/16/2020 */
(function(factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
Expand All @@ -13,7 +13,7 @@
})(function() {
"use strict";

var VERSION = "14.6.1";
var VERSION = "14.6.2";

//region Helper Methods

Expand Down Expand Up @@ -1640,6 +1640,13 @@
pointer = true;
}

// Erroneous events seem to be passed in occasionally on iOS/iPadOS after user finishes interacting with
// the slider. They appear to be of type MouseEvent, yet they don't have usual properties set. Ignore
// events that have no touches or buttons associated with them. (#1057, #1079, #1095)
if (e.type === "mousedown" && !e.buttons && !e.touches) {
return false;
}

// The only thing one handle should be concerned about is the touches that originated on top of it.
if (touch) {
// Returns true if a touch originated on the target.
Expand Down Expand Up @@ -1880,13 +1887,6 @@

// Move closest handle to tapped location.
function eventTap(event) {
// Erroneous events seem to be passed in occasionally on iOS/iPadOS after user finishes interacting with
// the slider. They appear to be of type MouseEvent, yet they don't have usual properties set. Ignore tap
// events that have no touches or buttons associated with them.
if (!event.buttons && !event.touches) {
return false;
}

// The tap event shouldn't propagate up
event.stopPropagation();

Expand Down Expand Up @@ -2298,8 +2298,11 @@
}

// Test suggested values and apply margin, step.
function setHandle(handleNumber, to, lookBackward, lookForward) {
to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false);
// if exactInput is true, don't run checkHandlePosition, then the handle can be placed in between steps (#436)
function setHandle(handleNumber, to, lookBackward, lookForward, exactInput) {
if (!exactInput) {
to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false);
}

if (to === false) {
return false;
Expand Down Expand Up @@ -2364,7 +2367,7 @@
}

// Set the slider value.
function valueSet(input, fireSetEvent) {
function valueSet(input, fireSetEvent, exactInput) {
var values = asArray(input);
var isInit = scope_Locations[0] === undefined;

Expand All @@ -2379,7 +2382,7 @@

// First pass, without lookAhead but with lookBackward. Values are set from left to right.
scope_HandleNumbers.forEach(function(handleNumber) {
setHandle(handleNumber, resolveToValue(values[handleNumber], handleNumber), true, false);
setHandle(handleNumber, resolveToValue(values[handleNumber], handleNumber), true, false, exactInput);
});

var i = scope_HandleNumbers.length === 1 ? 0 : 1;
Expand All @@ -2388,7 +2391,7 @@
// Iterate all handles to ensure constraints are applied for the entire slider (Issue #1009)
for (; i < scope_HandleNumbers.length; ++i) {
scope_HandleNumbers.forEach(function(handleNumber) {
setHandle(handleNumber, scope_Locations[handleNumber], true, true);
setHandle(handleNumber, scope_Locations[handleNumber], true, true, exactInput);
});
}

Expand All @@ -2410,7 +2413,7 @@
}

// Set value for a single handle
function valueSetHandle(handleNumber, value, fireSetEvent) {
function valueSetHandle(handleNumber, value, fireSetEvent, exactInput) {
// Ensure numeric input
handleNumber = Number(handleNumber);

Expand All @@ -2419,7 +2422,8 @@
}

// Look both backward and forward, since we don't want this handle to "push" other handles (#960);
setHandle(handleNumber, resolveToValue(value, handleNumber), true, true);
// The exactInput argument can be used to ignore slider stepping (#436)
setHandle(handleNumber, resolveToValue(value, handleNumber), true, true, exactInput);

fireEvent("update", handleNumber);

Expand Down
2 changes: 1 addition & 1 deletion distribute/nouislider.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions distribute/nouislider.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nouislider",
"version": "14.6.1",
"version": "14.6.2",
"main": "distribute/nouislider.js",
"style": "distribute/nouislider.min.css",
"license": "MIT",
Expand Down

0 comments on commit 5e026db

Please sign in to comment.