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

Skip to content

Commit 1843254

Browse files
author
Valentin Hervieu
committed
Add a stepsArray option
This is to ease to use of non linear/number steps. As suggested in angular-slider#163
1 parent cc329a2 commit 1843254

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

demo/demo.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,11 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
6565
}
6666
};
6767

68-
//Slider config with custom display function displaying letters
69-
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
68+
//Slider config with steps array of letters
7069
$scope.slider_alphabet = {
7170
value: 0,
7271
options: {
73-
ceil: alphabet.length - 1,
74-
floor: 0,
75-
translate: function(value) {
76-
if (value >= 0 && value < alphabet.length)
77-
return alphabet[value];
78-
return '';
79-
}
72+
stepsArray:'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
8073
}
8174
};
8275

dist/rzslider.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
step: 1,
3939
precision: 0,
4040
translate: null,
41+
stepsArray: null,
4142
draggableRange: false,
4243
showSelectionBar: false,
4344
hideLimitLabels: false,
@@ -357,7 +358,16 @@
357358
this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
358359
this.options.draggableRange = this.range && this.options.draggableRange;
359360
this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
360-
if (this.options.translate)
361+
362+
if(this.options.stepsArray) {
363+
this.options.floor = 0;
364+
this.options.ceil = this.options.stepsArray.length -1;
365+
this.options.step = 1;
366+
this.customTrFn = function(value) {
367+
return this.options.stepsArray[value];
368+
};
369+
}
370+
else if (this.options.translate)
361371
this.customTrFn = this.options.translate;
362372
else
363373
this.customTrFn = function(value) {

dist/rzslider.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rzslider.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
step: 1,
3939
precision: 0,
4040
translate: null,
41+
stepsArray: null,
4142
draggableRange: false,
4243
showSelectionBar: false,
4344
hideLimitLabels: false,
@@ -357,7 +358,16 @@
357358
this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
358359
this.options.draggableRange = this.range && this.options.draggableRange;
359360
this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
360-
if (this.options.translate)
361+
362+
if(this.options.stepsArray) {
363+
this.options.floor = 0;
364+
this.options.ceil = this.options.stepsArray.length -1;
365+
this.options.step = 1;
366+
this.customTrFn = function(value) {
367+
return this.options.stepsArray[value];
368+
};
369+
}
370+
else if (this.options.translate)
361371
this.customTrFn = this.options.translate;
362372
else
363373
this.customTrFn = function(value) {

0 commit comments

Comments
 (0)