Commit 0873e9c0 authored by Valentin Hervieu's avatar Valentin Hervieu

fix(draggableRangeOnly): Fix the floor limit when floor is different than 0

Closes #293
parent 228c2687
/*! angularjs-slider - v2.10.3 -
(c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> -
https://github.com/angular-slider/angularjs-slider -
2016-03-14 */
2016-03-16 */
/*jslint unparam: true */
/*global angular: false, console: false, define, module */
(function(root, factory) {
......@@ -1594,9 +1594,9 @@
if (type === 'min') {
if (outOfBounds) {
if (isAbove) {
value = isRTL ? value : this.maxValue - this.dragging.difference;
value = isRTL ? this.minValue : this.maxValue - this.dragging.difference;
} else {
value = isRTL ? this.maxValue - this.dragging.difference : value;
value = isRTL ? this.maxValue - this.dragging.difference : this.minValue;
}
} else {
value = isRTL ? this.offsetToValue(newOffset + this.dragging.lowLimit) : this.offsetToValue(newOffset - this.dragging.lowLimit)
......@@ -1617,8 +1617,6 @@
}
}
return this.roundStep(value);
},
/**
......
This diff is collapsed.
......@@ -1598,9 +1598,9 @@
if (type === 'min') {
if (outOfBounds) {
if (isAbove) {
value = isRTL ? value : this.maxValue - this.dragging.difference;
value = isRTL ? this.minValue : this.maxValue - this.dragging.difference;
} else {
value = isRTL ? this.maxValue - this.dragging.difference : value;
value = isRTL ? this.maxValue - this.dragging.difference : this.minValue;
}
} else {
value = isRTL ? this.offsetToValue(newOffset + this.dragging.lowLimit) : this.offsetToValue(newOffset - this.dragging.lowLimit)
......@@ -1621,8 +1621,6 @@
}
}
return this.roundStep(value);
},
/**
......
......@@ -100,7 +100,7 @@
helper.slider.callOnChange.called.should.be.true;
});
it('should handle click on selbar and move move range when near 0 and moved left', function() {
it('should handle click on selbar and move range when near 0 and moved left', function() {
helper.scope.slider.min = 10;
helper.scope.$digest();
......@@ -124,7 +124,7 @@
expect(helper.slider.tracking).to.equal('rzSliderModel');
});
it('should handle click on selbar and move move range when near max and moved right', function() {
it('should handle click on selbar and move range when near max and moved right', function() {
helper.scope.slider.max = 90;
helper.scope.$digest();
......@@ -147,6 +147,21 @@
expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel');
});
it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() {
helper.scope.slider.min = 1050;
helper.scope.slider.max = 1550;
helper.scope.slider.options.floor = 1000;
helper.scope.slider.options.ceil = 5000;
helper.scope.$digest();
helper.fireMousedown(helper.slider.selBar, 0);
helper.fireMousemove(-1000);
expect(helper.scope.slider.min).to.equal(1000);
expect(helper.scope.slider.max).to.equal(1500);
expect(helper.slider.tracking).to.equal('rzSliderModel');
});
});
describe('Right to left Mouse controls - draggableRangeOnly Horizontal', function() {
......@@ -249,7 +264,7 @@
helper.slider.callOnChange.called.should.be.true;
});
it('should handle click on selbar and move move range when near 0 and moved left', function() {
it('should handle click on selbar and move range when near 0 and moved left', function() {
helper.scope.slider.min = 10;
helper.scope.$digest();
......@@ -273,7 +288,7 @@
expect(helper.slider.tracking).to.equal('rzSliderModel');
});
it('should handle click on selbar and move move range when near max and moved right', function() {
it('should handle click on selbar and move range when near max and moved right', function() {
helper.scope.slider.max = 90;
helper.scope.$digest();
......@@ -296,6 +311,21 @@
expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel');
});
it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() {
helper.scope.slider.min = 1050;
helper.scope.slider.max = 1550;
helper.scope.slider.options.floor = 1000;
helper.scope.slider.options.ceil = 5000;
helper.scope.$digest();
helper.fireMousedown(helper.slider.selBar, 0);
helper.fireMousemove(-1000);
expect(helper.scope.slider.min).to.equal(1000);
expect(helper.scope.slider.max).to.equal(1500);
expect(helper.slider.tracking).to.equal('rzSliderModel');
});
});
}());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment