Skip to content

Commit 8a7fcbc

Browse files
committed
Merge pull request #67 from ValentinH/RzSliderOnChange
Add a rzSliderOnChange attribute.
2 parents b405f12 + 2faa6df commit 8a7fcbc

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
@@ -110,6 +110,10 @@ $scope.priceSlider = {
110110

111111
> 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:
112112
113+
**rz-slider-on-change**
114+
115+
> Function to be called when rz-slider-model or rz-slider-high change.
116+
113117
```javascript
114118
// In your controller
115119

@@ -132,7 +136,8 @@ $scope.translate = function(value)
132136
rz-slider-ceil="priceSlider.ceil"
133137
rz-slider-model="priceSlider.min"
134138
rz-slider-high="priceSlider.max"
135-
rz-slider-translate="translate"></rzslider>
139+
rz-slider-translate="translate"
140+
rz-slider-on-change="onSliderChange()"></rzslider>
136141
```
137142

138143
## Slider events

rzslider.js

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

562+
/**
563+
* Call the onChange callback if defined
564+
*
565+
* @returns {undefined}
566+
*/
567+
callOnChange: function() {
568+
if(this.scope.rzSliderOnChange) {
569+
this.scope.rzSliderOnChange();
570+
}
571+
},
572+
562573
/**
563574
* Update slider handles and label positions
564575
*
@@ -567,6 +578,7 @@ function throttle(func, wait, options) {
567578
*/
568579
updateHandles: function(which, newOffset)
569580
{
581+
this.callOnChange();
570582
if(which === 'rzSliderModel')
571583
{
572584
this.updateLowHandle(newOffset);
@@ -1048,7 +1060,8 @@ function throttle(func, wait, options) {
10481060
rzSliderTranslate: '&',
10491061
rzSliderHideLimitLabels: '=?',
10501062
rzSliderAlwaysShowBar: '=?',
1051-
rzSliderPresentOnly: '@'
1063+
rzSliderPresentOnly: '@',
1064+
rzSliderOnChange: '&'
10521065
},
10531066

10541067
/**

0 commit comments

Comments
 (0)