Commit 8a7fcbca authored by Valentin Hervieu's avatar Valentin Hervieu

Merge pull request #67 from ValentinH/RzSliderOnChange

Add a rzSliderOnChange attribute. 
parents b405f126 2faa6dfb
...@@ -110,6 +110,10 @@ $scope.priceSlider = { ...@@ -110,6 +110,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
...@@ -132,7 +136,8 @@ $scope.translate = function(value) ...@@ -132,7 +136,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
......
...@@ -559,6 +559,17 @@ function throttle(func, wait, options) { ...@@ -559,6 +559,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
* *
...@@ -567,6 +578,7 @@ function throttle(func, wait, options) { ...@@ -567,6 +578,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);
...@@ -1048,7 +1060,8 @@ function throttle(func, wait, options) { ...@@ -1048,7 +1060,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