Skip to content

Commit 664d118

Browse files
committed
fix(draggableRange): Fix minLimit/maxLimit bugged for draggableRange
Close #384
1 parent 324ea00 commit 664d118

9 files changed

+55
-9
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 5.4.3 (2016-08-07)
2+
## Fix
3+
- Fix minLimit/maxLimit bugged for draggableRange (#384).
4+
15
# 5.4.2 (2016-08-02)
26
## Fix
37
- Fix minimum value goes below floor when using maxRange (#377).

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-slider",
3-
"version": "5.4.2",
3+
"version": "5.4.3",
44
"homepage": "https://github.com/angular-slider/angularjs-slider",
55
"authors": [
66
"Rafal Zajac <[email protected]>",

dist/rzslider.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*! angularjs-slider - v5.4.2 -
1+
/*! angularjs-slider - v5.4.3 -
22
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
33
https://github.com/angular-slider/angularjs-slider -
4-
2016-08-02 */
4+
2016-08-07 */
55
.rzslider {
66
position: relative;
77
display: inline-block;

dist/rzslider.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/*! angularjs-slider - v5.4.2 -
1+
/*! angularjs-slider - v5.4.3 -
22
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
33
https://github.com/angular-slider/angularjs-slider -
4-
2016-08-02 */
4+
2016-08-07 */
55
/*jslint unparam: true */
66
/*global angular: false, console: false, define, module */
77
(function(root, factory) {
@@ -1915,6 +1915,16 @@
19151915
* @param {number} newMaxValue the new maximum value
19161916
*/
19171917
positionTrackingBar: function(newMinValue, newMaxValue) {
1918+
1919+
if (this.options.minLimit != null && newMinValue < this.options.minLimit) {
1920+
newMinValue = this.options.minLimit;
1921+
newMaxValue = newMinValue + this.dragging.difference;
1922+
}
1923+
if (this.options.maxLimit != null && newMaxValue > this.options.maxLimit){
1924+
newMaxValue = this.options.maxLimit;
1925+
newMinValue = newMaxValue - this.dragging.difference;
1926+
}
1927+
19181928
this.lowValue = newMinValue;
19191929
this.highValue = newMaxValue;
19201930
this.applyLowValue();

dist/rzslider.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-slider",
3-
"version": "5.4.2",
3+
"version": "5.4.3",
44
"description": "AngularJS slider directive with no external dependencies. Mobile friendly!.",
55
"main": "dist/rzslider.js",
66
"repository": {

src/rzslider.js

+10
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,16 @@
19191919
* @param {number} newMaxValue the new maximum value
19201920
*/
19211921
positionTrackingBar: function(newMinValue, newMaxValue) {
1922+
1923+
if (this.options.minLimit != null && newMinValue < this.options.minLimit) {
1924+
newMinValue = this.options.minLimit;
1925+
newMaxValue = newMinValue + this.dragging.difference;
1926+
}
1927+
if (this.options.maxLimit != null && newMaxValue > this.options.maxLimit){
1928+
newMaxValue = this.options.maxLimit;
1929+
newMinValue = newMaxValue - this.dragging.difference;
1930+
}
1931+
19221932
this.lowValue = newMinValue;
19231933
this.highValue = newMaxValue;
19241934
this.applyLowValue();

tests/specs/mouse-controls/draggable-range-slider-horizontal-test.js

+22
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,28 @@
196196
expect(helper.slider.minH.css('left')).to.equal(minOffset + 'px');
197197
expect(helper.slider.maxH.css('left')).to.equal(maxOffset + 'px');
198198
});
199+
200+
it('should respect minLimit option', function() {
201+
helper.scope.slider.options.minLimit = 20;
202+
helper.scope.$digest();
203+
204+
helper.fireMousedown(helper.slider.selBar, 0);
205+
helper.fireMousemove(-1000);
206+
207+
expect(helper.scope.slider.min).to.equal(20);
208+
expect(helper.scope.slider.max).to.equal(40);
209+
});
210+
211+
it('should respect maxLimit option', function() {
212+
helper.scope.slider.options.maxLimit = 80;
213+
helper.scope.$digest();
214+
215+
helper.fireMousedown(helper.slider.selBar, 0);
216+
helper.fireMousemove(helper.slider.maxPos);
217+
218+
expect(helper.scope.slider.min).to.equal(60);
219+
expect(helper.scope.slider.max).to.equal(80);
220+
});
199221
});
200222

201223
describe('Right to left Mouse controls - draggableRange Horizontal', function() {

0 commit comments

Comments
 (0)