Skip to content

Commit

Permalink
fix(slider): no minimum step for label generator
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJltres authored Oct 4, 2020
1 parent 9fc8329 commit fcd221b
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/definitions/modules/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,28 +205,26 @@ $.fn.slider = function(parameters) {
});
},
autoLabel: function() {
if(module.get.step() != 0) {
$labels = $module.find('.labels');
if($labels.length != 0) {
$labels.empty();
}
else {
$labels = $module.append('<ul class="auto labels"></ul>').find('.labels');
}
for(var i = 0, len = module.get.numLabels(); i <= len; i++) {
var
labelText = module.get.label(i),
$label = (labelText !== "")
? !(i % module.get.gapRatio())
? $('<li class="label">' + labelText + '</li>')
: $('<li class="halftick label"></li>')
: null,
ratio = i / len
;
if($label) {
module.update.labelPosition(ratio, $label);
$labels.append($label);
}
$labels = $module.find('.labels');
if($labels.length != 0) {
$labels.empty();
}
else {
$labels = $module.append('<ul class="auto labels"></ul>').find('.labels');
}
for(var i = 0, len = module.get.numLabels(); i <= len; i++) {
var
labelText = module.get.label(i),
$label = (labelText !== "")
? !(i % module.get.gapRatio())
? $('<li class="label">' + labelText + '</li>')
: $('<li class="halftick label"></li>')
: null,
ratio = i / len
;
if($label) {
module.update.labelPosition(ratio, $label);
$labels.append($label);
}
}
}
Expand Down Expand Up @@ -591,7 +589,7 @@ $.fn.slider = function(parameters) {

switch (settings.labelType) {
case settings.labelTypes.number:
return Math.round(((value * module.get.step()) + module.get.min()) * precision ) / precision;
return Math.round(((value * (module.get.step() === 0 ? 1 : module.get.step())) + module.get.min()) * precision ) / precision;
case settings.labelTypes.letter:
return alphabet[(value) % 26];
default:
Expand Down

0 comments on commit fcd221b

Please sign in to comment.