Commit 1843254e authored by Valentin Hervieu's avatar Valentin Hervieu

Add a stepsArray option

This is to ease to use of non linear/number steps. As suggested in #163
parent cc329a2a
......@@ -65,18 +65,11 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
}
};
//Slider config with custom display function displaying letters
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
//Slider config with steps array of letters
$scope.slider_alphabet = {
value: 0,
options: {
ceil: alphabet.length - 1,
floor: 0,
translate: function(value) {
if (value >= 0 && value < alphabet.length)
return alphabet[value];
return '';
}
stepsArray:'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
}
};
......
......@@ -38,6 +38,7 @@
step: 1,
precision: 0,
translate: null,
stepsArray: null,
draggableRange: false,
showSelectionBar: false,
hideLimitLabels: false,
......@@ -357,7 +358,16 @@
this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
this.options.draggableRange = this.range && this.options.draggableRange;
this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
if (this.options.translate)
if(this.options.stepsArray) {
this.options.floor = 0;
this.options.ceil = this.options.stepsArray.length -1;
this.options.step = 1;
this.customTrFn = function(value) {
return this.options.stepsArray[value];
};
}
else if (this.options.translate)
this.customTrFn = this.options.translate;
else
this.customTrFn = function(value) {
......
This diff is collapsed.
......@@ -38,6 +38,7 @@
step: 1,
precision: 0,
translate: null,
stepsArray: null,
draggableRange: false,
showSelectionBar: false,
hideLimitLabels: false,
......@@ -357,7 +358,16 @@
this.range = this.scope.rzSliderModel !== undefined && this.scope.rzSliderHigh !== undefined;
this.options.draggableRange = this.range && this.options.draggableRange;
this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
if (this.options.translate)
if(this.options.stepsArray) {
this.options.floor = 0;
this.options.ceil = this.options.stepsArray.length -1;
this.options.step = 1;
this.customTrFn = function(value) {
return this.options.stepsArray[value];
};
}
else if (this.options.translate)
this.customTrFn = this.options.translate;
else
this.customTrFn = function(value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment