beam: align zoom slider with engine controls

This commit is contained in:
CODEX
2026-06-04 23:33:28 +03:00
parent 6d65b2ba41
commit 43accba61c
3 changed files with 104 additions and 37 deletions
+22 -2
View File
@@ -27,11 +27,30 @@ export function createSliderControl({
const valueEl = document.createElement("div");
valueEl.className = "slider-value";
const fillText = document.createElement("span");
fillText.className = "slider-fill-text";
fillText.setAttribute("aria-hidden", "true");
const fillLabel = document.createElement("span");
fillLabel.textContent = label;
fillLabel.className = "slider-label";
const fillValue = document.createElement("span");
fillValue.className = "slider-value";
fillText.appendChild(fillLabel);
fillText.appendChild(fillValue);
const updateFill = () => {
const percent = ((input.value - input.min) / (input.max - input.min)) * 100;
const range = Number(input.max) - Number(input.min);
const percent = range
? Math.max(0, Math.min(100, ((Number(input.value) - Number(input.min)) / range) * 100))
: 0;
row.style.setProperty("--slider-percent", `${percent}%`);
input.style.setProperty("--slider-percent", `${percent}%`);
if (showValue) {
valueEl.textContent = formatValue(Number(input.value));
const formattedValue = formatValue(Number(input.value));
valueEl.textContent = formattedValue;
fillValue.textContent = formattedValue;
}
};
@@ -47,6 +66,7 @@ export function createSliderControl({
row.appendChild(input);
if (showValue) {
row.appendChild(valueEl);
row.appendChild(fillText);
}
row.setValue = (nextValue) => {
input.value = nextValue;