Skip to content

Commit 2faa6df

Browse files
author
Valentin Hervieu
committed
Add a rzSliderOnChange attribute. <rzslider rz-slider-model="priceSlider" rz-slider-on-change="onSliderChange()"></rzslider>
1 parent f253533 commit 2faa6df

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ $scope.priceSlider = {
106106

107107
> 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:
108108
109+
**rz-slider-on-change**
110+
111+
> Function to be called when rz-slider-model or rz-slider-high change.
112+
109113
```javascript
110114
// In your controller
111115

@@ -128,7 +132,8 @@ $scope.translate = function(value)
128132
rz-slider-ceil="priceSlider.ceil"
129133
rz-slider-model="priceSlider.min"
130134
rz-slider-high="priceSlider.max"
131-
rz-slider-translate="translate"></rzslider>
135+
rz-slider-translate="translate"
136+
rz-slider-on-change="onSliderChange()"></rzslider>
132137
```
133138

134139
## Slider events

rzslider.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,17 @@ function throttle(func, wait, options) {
560560
this.getWidth(this.flrLab);
561561
},
562562

563+
/**
564+
* Call the onChange callback if defined
565+
*
566+
* @returns {undefined}
567+
*/
568+
callOnChange: function() {
569+
if(this.scope.rzSliderOnChange) {
570+
this.scope.rzSliderOnChange();
571+
}
572+
},
573+
563574
/**
564575
* Update slider handles and label positions
565576
*
@@ -568,6 +579,7 @@ function throttle(func, wait, options) {
568579
*/
569580
updateHandles: function(which, newOffset)
570581
{
582+
this.callOnChange();
571583
if(which === 'rzSliderModel')
572584
{
573585
this.updateLowHandle(newOffset);
@@ -1033,7 +1045,8 @@ function throttle(func, wait, options) {
10331045
rzSliderTranslate: '&',
10341046
rzSliderHideLimitLabels: '=?',
10351047
rzSliderAlwaysShowBar: '=?',
1036-
rzSliderPresentOnly: '@'
1048+
rzSliderPresentOnly: '@',
1049+
rzSliderOnChange: '&'
10371050
},
10381051

10391052
/**

0 commit comments

Comments
 (0)