Update NumberStepper

This commit is contained in:
redphx
2024-10-22 16:52:23 +07:00
parent 95881dd241
commit 33c3b2810a
4 changed files with 26 additions and 17 deletions

View File

@@ -789,10 +789,12 @@ class SettingElement {
}), $wrapper.appendChild($range), options.ticks || options.exactTicks) {
let markersId = `markers-${key}`, $markers = CE("datalist", { id: markersId });
if ($range.setAttribute("list", markersId), options.exactTicks) {
let start = Math.max(Math.floor(MIN / options.exactTicks), 1) * options.exactTicks;
if (start === MIN) start += options.exactTicks;
for (let i = start;i < MAX; i += options.exactTicks)
$markers.appendChild(CE("option", { value: i }));
let start = Math.max(Math.floor(setting.min / options.exactTicks), 1) * options.exactTicks;
if (start === setting.min) start += options.exactTicks;
for (let i = start;i < setting.max; i += options.exactTicks)
$markers.appendChild(CE("option", {
value: options.reverse ? -i : i
}));
} else for (let i = MIN + options.ticks;i < MAX; i += options.ticks)
$markers.appendChild(CE("option", { value: i }));
$wrapper.appendChild($markers);
@@ -1383,9 +1385,10 @@ class GlobalSettingsStorage extends BaseSettingsStore {
type: "number-stepper",
default: 4,
min: 4,
max: 40,
max: 60,
steps: 4,
params: {
exactTicks: 20,
reverse: !0,
customTextValue(value) {
value = parseInt(value);

View File

@@ -812,10 +812,12 @@ class SettingElement {
}), $wrapper.appendChild($range), options.ticks || options.exactTicks) {
let markersId = `markers-${key}`, $markers = CE("datalist", { id: markersId });
if ($range.setAttribute("list", markersId), options.exactTicks) {
let start = Math.max(Math.floor(MIN / options.exactTicks), 1) * options.exactTicks;
if (start === MIN) start += options.exactTicks;
for (let i = start;i < MAX; i += options.exactTicks)
$markers.appendChild(CE("option", { value: i }));
let start = Math.max(Math.floor(setting.min / options.exactTicks), 1) * options.exactTicks;
if (start === setting.min) start += options.exactTicks;
for (let i = start;i < setting.max; i += options.exactTicks)
$markers.appendChild(CE("option", {
value: options.reverse ? -i : i
}));
} else for (let i = MIN + options.ticks;i < MAX; i += options.ticks)
$markers.appendChild(CE("option", { value: i }));
$wrapper.appendChild($markers);
@@ -1406,9 +1408,10 @@ class GlobalSettingsStorage extends BaseSettingsStore {
type: "number-stepper",
default: 4,
min: 4,
max: 40,
max: 60,
steps: 4,
params: {
exactTicks: 20,
reverse: !0,
customTextValue(value) {
value = parseInt(value);