|
34 | 34 | translate: null,
|
35 | 35 | stepsArray: null,
|
36 | 36 | draggableRange: false,
|
| 37 | + draggableRangeOnly: false, |
37 | 38 | showSelectionBar: false,
|
38 | 39 | hideLimitLabels: false,
|
39 | 40 | readOnly: false,
|
|
292 | 293 | // Recalculate stuff if view port dimensions have changed
|
293 | 294 | angular.element($window).on('resize', calcDimFn);
|
294 | 295 |
|
295 |
| - if (this.options.vertical) |
296 |
| - this.sliderElem.addClass('vertical'); |
297 |
| - |
298 | 296 | this.initHasRun = true;
|
299 | 297 |
|
300 | 298 | // Watch for changes to the model
|
|
369 | 367 |
|
370 | 368 | if (this.options.step <= 0)
|
371 | 369 | this.options.step = 1;
|
| 370 | + |
372 | 371 | this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
|
373 | 372 | this.options.draggableRange = this.range && this.options.draggableRange;
|
| 373 | + this.options.draggableRangeOnly = this.range && this.options.draggableRangeOnly; |
| 374 | + if (this.options.draggableRangeOnly) { |
| 375 | + this.options.draggableRange = true; |
| 376 | + } |
| 377 | + |
374 | 378 | this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
|
375 | 379 | this.scope.showTicks = this.options.showTicks; //scope is used in the template
|
376 | 380 |
|
|
486 | 490 | this.alwaysHide(this.cmbLab, this.options.showTicksValues || !this.range);
|
487 | 491 | this.alwaysHide(this.selBar, !this.range && !this.options.showSelectionBar);
|
488 | 492 |
|
| 493 | + if (this.options.vertical) |
| 494 | + this.sliderElem.addClass('vertical'); |
| 495 | + |
489 | 496 | if (this.options.draggableRange)
|
490 | 497 | this.selBar.addClass('rz-draggable');
|
491 | 498 | else
|
|
1143 | 1150 | barMove = this.onMove;
|
1144 | 1151 | }
|
1145 | 1152 |
|
1146 |
| - this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); |
1147 |
| - if (this.range) { |
1148 |
| - this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); |
1149 |
| - } |
1150 |
| - this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null)); |
1151 |
| - this.fullBar.on('mousedown', angular.bind(this, this.onMove, this.fullBar)); |
1152 | 1153 | this.selBar.on('mousedown', angular.bind(this, barStart, null, barTracking));
|
1153 | 1154 | this.selBar.on('mousedown', angular.bind(this, barMove, this.selBar));
|
1154 |
| - this.ticks.on('mousedown', angular.bind(this, this.onStart, null, null)); |
1155 |
| - this.ticks.on('mousedown', angular.bind(this, this.onMove, this.ticks)); |
1156 | 1155 |
|
1157 |
| - this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); |
1158 |
| - if (this.range) { |
1159 |
| - this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); |
| 1156 | + if (this.options.draggableRangeOnly) { |
| 1157 | + this.minH.on('mousedown', angular.bind(this, barStart, null, barTracking)); |
| 1158 | + if (this.range) { |
| 1159 | + this.maxH.on('mousedown', angular.bind(this, barStart, null, barTracking)); |
| 1160 | + } |
| 1161 | + } else { |
| 1162 | + this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); |
| 1163 | + if (this.range) { |
| 1164 | + this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); |
| 1165 | + } |
| 1166 | + this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null)); |
| 1167 | + this.fullBar.on('mousedown', angular.bind(this, this.onMove, this.fullBar)); |
| 1168 | + this.ticks.on('mousedown', angular.bind(this, this.onStart, null, null)); |
| 1169 | + this.ticks.on('mousedown', angular.bind(this, this.onMove, this.ticks)); |
1160 | 1170 | }
|
1161 |
| - this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null)); |
1162 |
| - this.fullBar.on('touchstart', angular.bind(this, this.onMove, this.fullBar)); |
| 1171 | + |
1163 | 1172 | this.selBar.on('touchstart', angular.bind(this, barStart, null, barTracking));
|
1164 | 1173 | this.selBar.on('touchstart', angular.bind(this, barMove, this.selBar));
|
1165 |
| - this.ticks.on('touchstart', angular.bind(this, this.onStart, null, null)); |
1166 |
| - this.ticks.on('touchstart', angular.bind(this, this.onMove, this.ticks)); |
| 1174 | + if (this.options.draggableRangeOnly) { |
| 1175 | + this.minH.on('touchstart', angular.bind(this, barStart, null, barTracking)); |
| 1176 | + if (this.range) { |
| 1177 | + this.maxH.on('touchstart', angular.bind(this, barStart, null, barTracking)); |
| 1178 | + } |
| 1179 | + } else { |
| 1180 | + this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); |
| 1181 | + if (this.range) { |
| 1182 | + this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); |
| 1183 | + } |
| 1184 | + this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null)); |
| 1185 | + this.fullBar.on('touchstart', angular.bind(this, this.onMove, this.fullBar)); |
| 1186 | + this.ticks.on('touchstart', angular.bind(this, this.onStart, null, null)); |
| 1187 | + this.ticks.on('touchstart', angular.bind(this, this.onMove, this.ticks)); |
| 1188 | + } |
1167 | 1189 |
|
1168 | 1190 | if (this.options.keyboardSupport) {
|
1169 | 1191 | this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel'));
|
|
1319 | 1341 |
|
1320 | 1342 | var newValue = this.roundStep(this.sanitizeValue(action)),
|
1321 | 1343 | newOffset = this.valueToOffset(newValue);
|
1322 |
| - this.positionTrackingHandle(newValue, newOffset); |
| 1344 | + if (!this.options.draggableRangeOnly) { |
| 1345 | + this.positionTrackingHandle(newValue, newOffset); |
| 1346 | + } else { |
| 1347 | + var difference = this.scope.rzSliderHigh - this.scope.rzSliderModel, |
| 1348 | + newMinOffset, newMaxOffset, |
| 1349 | + newMinValue, newMaxValue; |
| 1350 | + if (this.tracking === 'rzSliderModel') { |
| 1351 | + newMinValue = newValue; |
| 1352 | + newMinOffset = newOffset; |
| 1353 | + newMaxValue = newValue + difference; |
| 1354 | + if (newMaxValue > this.maxValue) return; |
| 1355 | + newMaxOffset = this.valueToOffset(newMaxValue); |
| 1356 | + } else { |
| 1357 | + newMaxValue = newValue; |
| 1358 | + newMaxOffset = newOffset; |
| 1359 | + newMinValue = newValue - difference; |
| 1360 | + if (newMinValue < this.minValue) return; |
| 1361 | + newMinOffset = this.valueToOffset(newMinValue); |
| 1362 | + } |
| 1363 | + this.positionTrackingBar(newMinValue, newMaxValue, newMinOffset, newMaxOffset); |
| 1364 | + } |
1323 | 1365 | },
|
1324 | 1366 |
|
1325 | 1367 | /**
|
|
1342 | 1384 | lowDist: offset - this.minH.rzsp,
|
1343 | 1385 | highDist: this.maxH.rzsp - offset
|
1344 | 1386 | };
|
1345 |
| - this.minH.addClass('rz-active'); |
1346 |
| - this.maxH.addClass('rz-active'); |
1347 | 1387 |
|
1348 | 1388 | this.onStart(pointer, ref, event);
|
1349 | 1389 | },
|
|
0 commit comments