Commit 2faa6dfb authored by Valentin Hervieu's avatar Valentin Hervieu

Add a rzSliderOnChange attribute. <rzslider rz-slider-model="priceSlider"…

Add a rzSliderOnChange attribute. <rzslider rz-slider-model="priceSlider" rz-slider-on-change="onSliderChange()"></rzslider>
parent f2535332
...@@ -106,6 +106,10 @@ $scope.priceSlider = { ...@@ -106,6 +106,10 @@ $scope.priceSlider = {
> Custom translate function. Use this if you want to translate values displayed on the slider. For example if you want to display dollar amounts instead of just numbers do this: > Custom translate function. Use this if you want to translate values displayed on the slider. For example if you want to display dollar amounts instead of just numbers do this:
**rz-slider-on-change**
> Function to be called when rz-slider-model or rz-slider-high change.
```javascript ```javascript
// In your controller // In your controller
...@@ -128,7 +132,8 @@ $scope.translate = function(value) ...@@ -128,7 +132,8 @@ $scope.translate = function(value)
rz-slider-ceil="priceSlider.ceil" rz-slider-ceil="priceSlider.ceil"
rz-slider-model="priceSlider.min" rz-slider-model="priceSlider.min"
rz-slider-high="priceSlider.max" rz-slider-high="priceSlider.max"
rz-slider-translate="translate"></rzslider> rz-slider-translate="translate"
rz-slider-on-change="onSliderChange()"></rzslider>
``` ```
## Slider events ## Slider events
......
...@@ -560,6 +560,17 @@ function throttle(func, wait, options) { ...@@ -560,6 +560,17 @@ function throttle(func, wait, options) {
this.getWidth(this.flrLab); this.getWidth(this.flrLab);
}, },
/**
* Call the onChange callback if defined
*
* @returns {undefined}
*/
callOnChange: function() {
if(this.scope.rzSliderOnChange) {
this.scope.rzSliderOnChange();
}
},
/** /**
* Update slider handles and label positions * Update slider handles and label positions
* *
...@@ -568,6 +579,7 @@ function throttle(func, wait, options) { ...@@ -568,6 +579,7 @@ function throttle(func, wait, options) {
*/ */
updateHandles: function(which, newOffset) updateHandles: function(which, newOffset)
{ {
this.callOnChange();
if(which === 'rzSliderModel') if(which === 'rzSliderModel')
{ {
this.updateLowHandle(newOffset); this.updateLowHandle(newOffset);
...@@ -1033,7 +1045,8 @@ function throttle(func, wait, options) { ...@@ -1033,7 +1045,8 @@ function throttle(func, wait, options) {
rzSliderTranslate: '&', rzSliderTranslate: '&',
rzSliderHideLimitLabels: '=?', rzSliderHideLimitLabels: '=?',
rzSliderAlwaysShowBar: '=?', rzSliderAlwaysShowBar: '=?',
rzSliderPresentOnly: '@' rzSliderPresentOnly: '@',
rzSliderOnChange: '&'
}, },
/** /**
......
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