Skip to content

Commit

Permalink
fix(draggableRange): Fix minLimit/maxLimit bugged for draggableRange
Browse files Browse the repository at this point in the history
Close #384
  • Loading branch information
ValentinH committed Aug 7, 2016
1 parent 324ea00 commit 664d118
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.4.3 (2016-08-07)
## Fix
- Fix minLimit/maxLimit bugged for draggableRange (#384).

# 5.4.2 (2016-08-02)
## Fix
- Fix minimum value goes below floor when using maxRange (#377).
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-slider",
"version": "5.4.2",
"version": "5.4.3",
"homepage": "https://github.com/angular-slider/angularjs-slider",
"authors": [
"Rafal Zajac <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions dist/rzslider.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! angularjs-slider - v5.4.2 -
/*! angularjs-slider - v5.4.3 -
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
https://github.com/angular-slider/angularjs-slider -
2016-08-02 */
2016-08-07 */
.rzslider {
position: relative;
display: inline-block;
Expand Down
14 changes: 12 additions & 2 deletions dist/rzslider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! angularjs-slider - v5.4.2 -
/*! angularjs-slider - v5.4.3 -
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
https://github.com/angular-slider/angularjs-slider -
2016-08-02 */
2016-08-07 */
/*jslint unparam: true */
/*global angular: false, console: false, define, module */
(function(root, factory) {
Expand Down Expand Up @@ -1915,6 +1915,16 @@
* @param {number} newMaxValue the new maximum value
*/
positionTrackingBar: function(newMinValue, newMaxValue) {

if (this.options.minLimit != null && newMinValue < this.options.minLimit) {
newMinValue = this.options.minLimit;
newMaxValue = newMinValue + this.dragging.difference;
}
if (this.options.maxLimit != null && newMaxValue > this.options.maxLimit){
newMaxValue = this.options.maxLimit;
newMinValue = newMaxValue - this.dragging.difference;
}

this.lowValue = newMinValue;
this.highValue = newMaxValue;
this.applyLowValue();
Expand Down
2 changes: 1 addition & 1 deletion dist/rzslider.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 dist/rzslider.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-slider",
"version": "5.4.2",
"version": "5.4.3",
"description": "AngularJS slider directive with no external dependencies. Mobile friendly!.",
"main": "dist/rzslider.js",
"repository": {
Expand Down
10 changes: 10 additions & 0 deletions src/rzslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,16 @@
* @param {number} newMaxValue the new maximum value
*/
positionTrackingBar: function(newMinValue, newMaxValue) {

if (this.options.minLimit != null && newMinValue < this.options.minLimit) {
newMinValue = this.options.minLimit;
newMaxValue = newMinValue + this.dragging.difference;
}
if (this.options.maxLimit != null && newMaxValue > this.options.maxLimit){
newMaxValue = this.options.maxLimit;
newMinValue = newMaxValue - this.dragging.difference;
}

this.lowValue = newMinValue;
this.highValue = newMaxValue;
this.applyLowValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,28 @@
expect(helper.slider.minH.css('left')).to.equal(minOffset + 'px');
expect(helper.slider.maxH.css('left')).to.equal(maxOffset + 'px');
});

it('should respect minLimit option', function() {
helper.scope.slider.options.minLimit = 20;
helper.scope.$digest();

helper.fireMousedown(helper.slider.selBar, 0);
helper.fireMousemove(-1000);

expect(helper.scope.slider.min).to.equal(20);
expect(helper.scope.slider.max).to.equal(40);
});

it('should respect maxLimit option', function() {
helper.scope.slider.options.maxLimit = 80;
helper.scope.$digest();

helper.fireMousedown(helper.slider.selBar, 0);
helper.fireMousemove(helper.slider.maxPos);

expect(helper.scope.slider.min).to.equal(60);
expect(helper.scope.slider.max).to.equal(80);
});
});

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

0 comments on commit 664d118

Please sign in to comment.