From 72110821d5a2aadb92e6d85e5ee4280be15022f9 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 10 Oct 2024 04:00:14 +1100 Subject: [PATCH] thrimbletrimmer: Show/hide transition duration if "cut" is selected --- thrimbletrimmer/scripts/edit.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/thrimbletrimmer/scripts/edit.js b/thrimbletrimmer/scripts/edit.js index 76353ee..1daa949 100644 --- a/thrimbletrimmer/scripts/edit.js +++ b/thrimbletrimmer/scripts/edit.js @@ -1439,10 +1439,17 @@ function rangeDefinitionDOM() { }), ); updateTransitionTypes([transitionType]); - const transitionDurationSection = makeElement("div", ["range-transition-duration-section"]); - if (transitionType.value == "") { - transitionDurationSection.classList.add("hidden"); - } + + // Duration always starts hidden because type always starts as cut. + const transitionDurationSection = makeElement("div", ["range-transition-duration-section", "hidden"]); + // Add/remove hidden when type changes + transitionType.addEventListener("change", (event) => { + if (transitionType.value === "") { + transitionDurationSection.classList.add("hidden"); + } else { + transitionDurationSection.classList.remove("hidden"); + } + }); const transitionDuration = makeElement("input", ["range-transition-duration"], { type: "text", value: "1",