Skip to content

Commit

Permalink
feat(slider): fixed gapratio variant
Browse files Browse the repository at this point in the history
  • Loading branch information
lubber-de committed Oct 25, 2024
1 parent 9e8d959 commit 4e08fa1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/definitions/modules/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,17 @@
$labels = $module.append('<ul class="auto labels"></ul>').find('.labels');
}
var step = module.get.step(),
precision = module.get.precision()
precision = module.get.precision(),
len = module.get.numLabels(),
ignoreLabels = len - (settings.autoAdjustLabels !== 'fixed' ? 0 : module.get.max().toString().length + 4)
;
for (var i = 0, len = module.get.numLabels(); i <= len; i++) {
for (var i = 0; i <= len; i++) {
var
stepValue = Math.round(((i * (step === 0 ? 1 : step)) + module.get.min()) * precision) / precision,
labelText = module.get.label(i, stepValue),
showLabel = settings.restrictedLabels.length === 0 || settings.restrictedLabels.indexOf(labelText) >= 0,
$label = labelText !== '' && (showLabel || settings.showLabelTicks === 'always')
? (!(i % module.get.gapRatio()) || i === len
? ((!(i % module.get.gapRatio()) && i < ignoreLabels) || i === len
? $('<li/>', { class: className.label, 'data-value': stepValue, html: showLabel ? labelText : '' })
: $('<li/>', { class: 'halftick label', 'data-value': stepValue }))
: null,
Expand Down Expand Up @@ -832,7 +834,7 @@
// and apply only if the modulo of the operation is an odd number.
if (trackLength > 0) {
while ((trackLength / numLabels) * gapCounter < settings.labelDistance) {
if (!((numLabels + primePlus) % gapCounter)) {
if (!((numLabels + primePlus) % gapCounter) || settings.autoAdjustLabels === 'fixed') {
gapRatio = gapCounter;
}
gapCounter += 1;
Expand Down

0 comments on commit 4e08fa1

Please sign in to comment.