Skip to content

Commit dbee934

Browse files
committed
v10.1.0
1 parent 1ae2b56 commit dbee934

File tree

8 files changed

+92
-33
lines changed

8 files changed

+92
-33
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ npm [(package)](https://www.npmjs.com/package/nouislider)
3131
Changelog
3232
---------
3333

34+
### 10.1.0 (*2017-07-26*)
35+
- Added: `multitouch` option (#793);
36+
3437
### 10.0.0 (*2017-05-28*)
3538
- Change: Change event listeners to be passive (#785);
3639
- Fixed: Pips are now updated when calling `updateOptions` (#669);

distribute/nouislider.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! nouislider - 10.0.0 - 2017-05-28 14:52:48 */
1+
/*! nouislider - 10.1.0 - 2017-07-28 13:09:54 */
22
/* Functional styling;
33
* These styles are required for noUiSlider to function.
44
* You don't need to change these rules to apply your design.

distribute/nouislider.js

Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! nouislider - 10.0.0 - 2017-05-28 14:52:48 */
1+
/*! nouislider - 10.1.0 - 2017-07-28 13:09:54 */
22

33
(function (factory) {
44

@@ -22,7 +22,7 @@
2222

2323
'use strict';
2424

25-
var VERSION = '10.0.0';
25+
var VERSION = '10.1.0';
2626

2727

2828
function isValidFormatter ( entry ) {
@@ -723,6 +723,14 @@
723723
};
724724
}
725725

726+
function testMultitouch ( parsed, entry ) {
727+
parsed.multitouch = entry;
728+
729+
if ( typeof entry !== 'boolean' ){
730+
throw new Error("noUiSlider (" + VERSION + "): 'multitouch' option must be a boolean.");
731+
}
732+
}
733+
726734
function testTooltips ( parsed, entry ) {
727735

728736
if ( entry === false ) {
@@ -832,6 +840,7 @@
832840
'limit': { r: false, t: testLimit },
833841
'padding': { r: false, t: testPadding },
834842
'behaviour': { r: true, t: testBehaviour },
843+
'multitouch': { r: true, t: testMultitouch },
835844
'ariaFormat': { r: false, t: testAriaFormat },
836845
'format': { r: false, t: testFormat },
837846
'tooltips': { r: false, t: testTooltips },
@@ -844,6 +853,7 @@
844853
'connect': false,
845854
'direction': 'ltr',
846855
'behaviour': 'tap',
856+
'multitouch': false,
847857
'orientation': 'horizontal',
848858
'cssPrefix' : 'noUi-',
849859
'cssClasses': {
@@ -931,14 +941,13 @@ function closure ( target, options, originalOptions ){
931941
var scope_Base;
932942
var scope_Handles;
933943
var scope_HandleNumbers = [];
934-
var scope_ActiveHandle = false;
944+
var scope_ActiveHandlesCount = 0;
935945
var scope_Connects;
936946
var scope_Spectrum = options.spectrum;
937947
var scope_Values = [];
938948
var scope_Events = {};
939949
var scope_Self;
940950
var scope_Pips;
941-
var scope_Listeners = null;
942951
var scope_Document = target.ownerDocument;
943952
var scope_DocumentElement = scope_Document.documentElement;
944953
var scope_Body = scope_Document.body;
@@ -1376,7 +1385,7 @@ function closure ( target, options, originalOptions ){
13761385
return false;
13771386
}
13781387

1379-
e = fixEvent(e, data.pageOffset);
1388+
e = fixEvent(e, data.pageOffset, data.target || element);
13801389

13811390
// Handle reject of multitouch
13821391
if ( !e ) {
@@ -1420,7 +1429,7 @@ function closure ( target, options, originalOptions ){
14201429
}
14211430

14221431
// Provide a clean event with standardized offset values.
1423-
function fixEvent ( e, pageOffset ) {
1432+
function fixEvent ( e, pageOffset, target ) {
14241433

14251434
// Filter the event to register the type, which can be
14261435
// touch, mouse or pointer. Offset changes need to be
@@ -1437,8 +1446,35 @@ function closure ( target, options, originalOptions ){
14371446
pointer = true;
14381447
}
14391448

1440-
if ( touch ) {
14411449

1450+
// In the event that multitouch is activated, the only thing one handle should be concerned
1451+
// about is the touches that originated on top of it.
1452+
if ( touch && options.multitouch ) {
1453+
// Returns true if a touch originated on the target.
1454+
var isTouchOnTarget = function (touch) {
1455+
return touch.target === target || target.contains(touch.target);
1456+
};
1457+
// In the case of touchstart events, we need to make sure there is still no more than one
1458+
// touch on the target so we look amongst all touches.
1459+
if (e.type === 'touchstart') {
1460+
var targetTouches = Array.prototype.filter.call(e.touches, isTouchOnTarget);
1461+
// Do not support more than one touch per handle.
1462+
if ( targetTouches.length > 1 ) {
1463+
return false;
1464+
}
1465+
x = targetTouches[0].pageX;
1466+
y = targetTouches[0].pageY;
1467+
} else {
1468+
// In the other cases, find on changedTouches is enough.
1469+
var targetTouch = Array.prototype.find.call(e.changedTouches, isTouchOnTarget);
1470+
// Cancel if the target touch has not moved.
1471+
if ( !targetTouch ) {
1472+
return false;
1473+
}
1474+
x = targetTouch.pageX;
1475+
y = targetTouch.pageY;
1476+
}
1477+
} else if ( touch ) {
14421478
// Fix bug when user touches with two or more fingers on mobile devices.
14431479
// It's useful when you have two or more sliders on one page,
14441480
// that can be touched simultaneously.
@@ -1616,26 +1652,27 @@ function closure ( target, options, originalOptions ){
16161652
function eventEnd ( event, data ) {
16171653

16181654
// The handle is no longer active, so remove the class.
1619-
if ( scope_ActiveHandle ) {
1620-
removeClass(scope_ActiveHandle, options.cssClasses.active);
1621-
scope_ActiveHandle = false;
1622-
}
1623-
1624-
// Remove cursor styles and text-selection events bound to the body.
1625-
if ( event.cursor ) {
1626-
scope_Body.style.cursor = '';
1627-
scope_Body.removeEventListener('selectstart', preventDefault);
1655+
if ( data.handle ) {
1656+
removeClass(data.handle, options.cssClasses.active);
1657+
scope_ActiveHandlesCount -= 1;
16281658
}
16291659

16301660
// Unbind the move and end events, which are added on 'start'.
1631-
scope_Listeners.forEach(function( c ) {
1661+
data.listeners.forEach(function( c ) {
16321662
scope_DocumentElement.removeEventListener(c[0], c[1]);
16331663
});
16341664

1635-
// Remove dragging class.
1636-
removeClass(scope_Target, options.cssClasses.drag);
1665+
if ( scope_ActiveHandlesCount === 0 ) {
1666+
// Remove dragging class.
1667+
removeClass(scope_Target, options.cssClasses.drag);
1668+
setZindex();
16371669

1638-
setZindex();
1670+
// Remove cursor styles and text-selection events bound to the body.
1671+
if ( event.cursor ) {
1672+
scope_Body.style.cursor = '';
1673+
scope_Body.removeEventListener('selectstart', preventDefault);
1674+
}
1675+
}
16391676

16401677
data.handleNumbers.forEach(function(handleNumber){
16411678
fireEvent('change', handleNumber);
@@ -1647,25 +1684,36 @@ function closure ( target, options, originalOptions ){
16471684
// Bind move events on document.
16481685
function eventStart ( event, data ) {
16491686

1687+
var handle;
16501688
if ( data.handleNumbers.length === 1 ) {
16511689

1652-
var handle = scope_Handles[data.handleNumbers[0]];
1690+
var handleOrigin = scope_Handles[data.handleNumbers[0]];
16531691

16541692
// Ignore 'disabled' handles
1655-
if ( handle.hasAttribute('disabled') ) {
1693+
if ( handleOrigin.hasAttribute('disabled') ) {
16561694
return false;
16571695
}
16581696

1697+
handle = handleOrigin.children[0];
1698+
scope_ActiveHandlesCount += 1;
1699+
16591700
// Mark the handle as 'active' so it can be styled.
1660-
scope_ActiveHandle = handle.children[0];
1661-
addClass(scope_ActiveHandle, options.cssClasses.active);
1701+
addClass(handle, options.cssClasses.active);
16621702
}
16631703

16641704
// A drag should never propagate up to the 'tap' event.
16651705
event.stopPropagation();
16661706

1707+
// Record the event listeners.
1708+
var listeners = [];
1709+
16671710
// Attach the move and end events.
16681711
var moveEvent = attachEvent(actions.move, scope_DocumentElement, eventMove, {
1712+
// The event target has changed so we need to propagate the original one so that we keep
1713+
// relying on it to extract target touches.
1714+
target: event.target,
1715+
handle: handle,
1716+
listeners: listeners,
16691717
startCalcPoint: event.calcPoint,
16701718
baseSize: baseSize(),
16711719
pageOffset: event.pageOffset,
@@ -1675,14 +1723,22 @@ function closure ( target, options, originalOptions ){
16751723
});
16761724

16771725
var endEvent = attachEvent(actions.end, scope_DocumentElement, eventEnd, {
1726+
target: event.target,
1727+
handle: handle,
1728+
listeners: listeners,
16781729
handleNumbers: data.handleNumbers
16791730
});
16801731

16811732
var outEvent = attachEvent("mouseout", scope_DocumentElement, documentLeave, {
1733+
target: event.target,
1734+
handle: handle,
1735+
listeners: listeners,
16821736
handleNumbers: data.handleNumbers
16831737
});
16841738

1685-
scope_Listeners = moveEvent.concat(endEvent, outEvent);
1739+
// We want to make sure we pushed the listeners in the listener list rather than creating
1740+
// a new one as it has already been passed to the event handlers.
1741+
listeners.push.apply(listeners, moveEvent.concat(endEvent, outEvent));
16861742

16871743
// Text selection isn't an issue on touch devices,
16881744
// so adding cursor styles can be skipped.

distribute/nouislider.min.css

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

distribute/nouislider.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.

documentation/_run/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<link href="/nouislider/documentation/assets/prism.css" rel="stylesheet">
1414
<script src="/nouislider/documentation/assets/wNumb.js"></script>
1515

16-
<link href="<?php echo $distribute; ?>/nouislider.css?v=1000" rel="stylesheet">
17-
<script src="<?php echo $distribute; ?>/nouislider.js?v=1000"></script>
16+
<link href="<?php echo $distribute; ?>/nouislider.css?v=1010" rel="stylesheet">
17+
<script src="<?php echo $distribute; ?>/nouislider.js?v=1010"></script>
1818
<?php /* <script src="/nouislider/concat.php"></script> */ ?>
1919

2020
</head>

documentation/download.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<p>noUiSlider is open source, and you can use it <strong>for free</strong> in any personal or commercial product. No attribution required. Both the uncompressed and compressed version of noUiSlider are available in a <code>.zip</code> release, which is hosted by Github and available over <code>https</code>.</p>
1313

14-
<a class="button" href="https://github.com/leongersen/noUiSlider/releases/download/10.0.0/noUiSlider.10.0.0.zip" data-category="convert" data-action="download">Download noUiSlider from Github</a>
14+
<a class="button" href="https://github.com/leongersen/noUiSlider/releases/download/10.1.0/noUiSlider.10.1.0.zip" data-category="convert" data-action="download">Download noUiSlider from Github</a>
1515

1616
<div class="share">
1717
<iframe src="https://ghbtns.com/github-btn.html?user=leongersen&repo=noUiSlider&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nouislider",
3-
"version": "10.0.0",
3+
"version": "10.1.0",
44
"main": "distribute/nouislider",
55
"style": "distribute/nouislider.min.css",
66
"license": "WTFPL",

0 commit comments

Comments
 (0)