Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e3cdbe

Browse files
author
Valentin Hervieu
committed
feat(onlyBindHandles): Add an onlyBindHandles option.
Set to true to only bind events on slider handles.
1 parent dbab13d commit 2e3cdbe

File tree

5 files changed

+87
-35
lines changed

5 files changed

+87
-35
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ The default options are:
175175
keyboardSupport: true,
176176
scale: 1,
177177
enforceRange: false,
178+
onlyBindHandles: false,
178179
onStart: null,
179180
onChange: null,
180181
onEnd: null
@@ -242,6 +243,8 @@ $scope.slider = {
242243

243244
**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.
244245

246+
**onlyBindHandles** - _Boolean (defaults to false)_: Set to true to only bind events on slider handles.
247+
245248
**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.
246249

247250
**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.

dist/rzslider.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
keyboardSupport: true,
5050
scale: 1,
5151
enforceRange: false,
52+
onlyBindHandles: false,
5253
onStart: null,
5354
onChange: null,
5455
onEnd: null
@@ -1197,8 +1198,10 @@
11971198
barMove = this.onMove;
11981199
}
11991200

1200-
this.selBar.on('mousedown', angular.bind(this, barStart, null, barTracking));
1201-
this.selBar.on('mousedown', angular.bind(this, barMove, this.selBar));
1201+
if (!this.options.onlyBindHandles) {
1202+
this.selBar.on('mousedown', angular.bind(this, barStart, null, barTracking));
1203+
this.selBar.on('mousedown', angular.bind(this, barMove, this.selBar));
1204+
}
12021205

12031206
if (this.options.draggableRangeOnly) {
12041207
this.minH.on('mousedown', angular.bind(this, barStart, null, barTracking));
@@ -1208,14 +1211,18 @@
12081211
if (this.range) {
12091212
this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh'));
12101213
}
1211-
this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null));
1212-
this.fullBar.on('mousedown', angular.bind(this, this.onMove, this.fullBar));
1213-
this.ticks.on('mousedown', angular.bind(this, this.onStart, null, null));
1214-
this.ticks.on('mousedown', angular.bind(this, this.onMove, this.ticks));
1214+
if (!this.options.onlyBindHandles) {
1215+
this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null));
1216+
this.fullBar.on('mousedown', angular.bind(this, this.onMove, this.fullBar));
1217+
this.ticks.on('mousedown', angular.bind(this, this.onStart, null, null));
1218+
this.ticks.on('mousedown', angular.bind(this, this.onMove, this.ticks));
1219+
}
12151220
}
12161221

1217-
this.selBar.on('touchstart', angular.bind(this, barStart, null, barTracking));
1218-
this.selBar.on('touchstart', angular.bind(this, barMove, this.selBar));
1222+
if (!this.options.onlyBindHandles) {
1223+
this.selBar.on('touchstart', angular.bind(this, barStart, null, barTracking));
1224+
this.selBar.on('touchstart', angular.bind(this, barMove, this.selBar));
1225+
}
12191226
if (this.options.draggableRangeOnly) {
12201227
this.minH.on('touchstart', angular.bind(this, barStart, null, barTracking));
12211228
this.maxH.on('touchstart', angular.bind(this, barStart, null, barTracking));
@@ -1224,10 +1231,12 @@
12241231
if (this.range) {
12251232
this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh'));
12261233
}
1227-
this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null));
1228-
this.fullBar.on('touchstart', angular.bind(this, this.onMove, this.fullBar));
1229-
this.ticks.on('touchstart', angular.bind(this, this.onStart, null, null));
1230-
this.ticks.on('touchstart', angular.bind(this, this.onMove, this.ticks));
1234+
if (!this.options.onlyBindHandles) {
1235+
this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null));
1236+
this.fullBar.on('touchstart', angular.bind(this, this.onMove, this.fullBar));
1237+
this.ticks.on('touchstart', angular.bind(this, this.onStart, null, null));
1238+
this.ticks.on('touchstart', angular.bind(this, this.onMove, this.ticks));
1239+
}
12311240
}
12321241

12331242
if (this.options.keyboardSupport) {

0 commit comments

Comments
 (0)