From 757901f96d83dfb8e4e9f611ace3c9d18b134ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Gersen?= Date: Sat, 14 Aug 2021 20:25:49 +0200 Subject: [PATCH] Add getPositions method --- documentation/reference.php | 5 +++++ documentation/slider-read-write.php | 16 ++++++++++++++++ documentation/slider-read-write/positions.js | 1 + src/nouislider.ts | 3 +++ 4 files changed, 25 insertions(+) create mode 100644 documentation/slider-read-write/positions.js diff --git a/documentation/reference.php b/documentation/reference.php index 0d75d572..39c1424b 100644 --- a/documentation/reference.php +++ b/documentation/reference.php @@ -251,6 +251,11 @@ slider.noUiSlider.removeTooltips() [none] + + getPositions + slider.noUiSlider.getPositions() + [none] + diff --git a/documentation/slider-read-write.php b/documentation/slider-read-write.php index 2b48df44..79776ec7 100644 --- a/documentation/slider-read-write.php +++ b/documentation/slider-read-write.php @@ -86,6 +86,22 @@ + +

Positions

+ +
+ +
+

To get the current positions for the slider handles (in percentages from the left of the slider), the getPositions method can be used. This matches the positions parameter in the slider's events.

+
+ +
+ +
+ +
+ +

Number formatting

diff --git a/documentation/slider-read-write/positions.js b/documentation/slider-read-write/positions.js new file mode 100644 index 00000000..a36b05ff --- /dev/null +++ b/documentation/slider-read-write/positions.js @@ -0,0 +1 @@ +slider.noUiSlider.getPositions(); diff --git a/src/nouislider.ts b/src/nouislider.ts index b2757504..32178655 100644 --- a/src/nouislider.ts +++ b/src/nouislider.ts @@ -2992,6 +2992,9 @@ function scope(target: TargetElement, options: ParsedOptions, originalOptions: O target: scope_Target, // Issue #597 removePips: removePips, removeTooltips: removeTooltips, + getPositions: function() { + return scope_Locations.slice(); + }, getTooltips: function() { return scope_Tooltips; },