Commit efcacbe9 authored by Valentin Hervieu's avatar Valentin Hervieu

feat(enforceRange): Add an enforceRange options.

Set to true to round the `rzSliderModel` and `rzSliderHigh` to the slider range even when modified from outside the slider. When set to false, if the model values are modified from outside the slider, they are not rounded but they are still rendered properly on the slider.

Closes #208.
parent c5c07a56
......@@ -172,6 +172,7 @@ The default options are:
selectionBarColor: null,
keyboardSupport: true,
scale: 1,
enforceRange: false,
onStart: null,
onChange: null,
onEnd: null
......@@ -235,6 +236,8 @@ $scope.slider = {
**scale** - _Number (defaults to 1)_: If you display the slider in an element that uses `transform: scale(0.5)`, set the `scale` value to 2 so that the slider is rendered properly and the events are handled correctly.
**enforceRange** - _Boolean (defaults to false)_: Set to true to round the `rzSliderModel` and `rzSliderHigh` to the slider range even when modified from outside the slider. When set to false, if the model values are modified from outside the slider, they are not rounded but they are still rendered properly on the slider.
**onStart** - _Function(sliderId)_: Function to be called when a slider update is started. If an id was set in the options, then it's passed to this callback.
**onChange** - _Function(sliderId)_: Function to be called when rz-slider-model or rz-slider-high change. If an id was set in the options, then it's passed to this callback.
......
......@@ -47,6 +47,7 @@
selectionBarColor: null,
keyboardSupport: true,
scale: 1,
enforceRange: false,
onStart: null,
onChange: null,
onEnd: null
......@@ -625,6 +626,12 @@
else
this.maxValue = this.options.ceil = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel;
if (this.options.enforceRange) {
this.scope.rzSliderModel = this.sanitizeValue(this.scope.rzSliderModel);
if (this.range)
this.scope.rzSliderHigh = this.sanitizeValue(this.scope.rzSliderHigh);
}
this.valueRange = this.maxValue - this.minValue;
},
......
This diff is collapsed.
......@@ -51,6 +51,7 @@
selectionBarColor: null,
keyboardSupport: true,
scale: 1,
enforceRange: false,
onStart: null,
onChange: null,
onEnd: null
......@@ -629,6 +630,12 @@
else
this.maxValue = this.options.ceil = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel;
if (this.options.enforceRange) {
this.scope.rzSliderModel = this.sanitizeValue(this.scope.rzSliderModel);
if (this.range)
this.scope.rzSliderHigh = this.sanitizeValue(this.scope.rzSliderHigh);
}
this.valueRange = this.maxValue - this.minValue;
},
......
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