beam: add zoom speed control

This commit is contained in:
CODEX
2026-06-04 23:22:00 +03:00
parent 1569ed9c23
commit 6d65b2ba41
4 changed files with 175 additions and 19 deletions
+26 -2
View File
@@ -1,6 +1,16 @@
export function createSliderControl({ label = "", value = 0, min = 0, max = 100, step = 1, onChange }) {
export function createSliderControl({
label = "",
value = 0,
min = 0,
max = 100,
step = 1,
className = "",
showValue = false,
formatValue = (val) => String(val),
onChange
}) {
const row = document.createElement("div");
row.className = "slider-row";
row.className = ["slider-row", className].filter(Boolean).join(" ");
const lbl = document.createElement("label");
lbl.textContent = label;
@@ -14,9 +24,15 @@ export function createSliderControl({ label = "", value = 0, min = 0, max = 100,
input.step = step;
input.value = value;
const valueEl = document.createElement("div");
valueEl.className = "slider-value";
const updateFill = () => {
const percent = ((input.value - input.min) / (input.max - input.min)) * 100;
input.style.setProperty("--slider-percent", `${percent}%`);
if (showValue) {
valueEl.textContent = formatValue(Number(input.value));
}
};
input.addEventListener("input", () => {
@@ -29,5 +45,13 @@ export function createSliderControl({ label = "", value = 0, min = 0, max = 100,
row.appendChild(lbl);
row.appendChild(input);
if (showValue) {
row.appendChild(valueEl);
}
row.setValue = (nextValue) => {
input.value = nextValue;
updateFill();
};
row.getValue = () => Number(input.value);
return row;
}