From f8de93a9f3ce73a83b27a830316f89008c0994a8 Mon Sep 17 00:00:00 2001 From: JotaChina Date: Sat, 27 Dec 2025 09:40:14 -0300 Subject: [PATCH] corrigindo play/stop do editor de patterns --- assets/js/creations/main.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/assets/js/creations/main.js b/assets/js/creations/main.js index 44953e40..822a014b 100755 --- a/assets/js/creations/main.js +++ b/assets/js/creations/main.js @@ -426,14 +426,13 @@ document.addEventListener("DOMContentLoaded", () => { inputs.forEach((input) => { input.addEventListener("input", (event) => { enforceNumericInput(event); - if ( - appState.global.isPlaying && - (event.target.id.startsWith("compasso-") || - event.target.id === "bars-input") - ) { + const id = event.target.id; + const affectsTimeline = id === "bars-input" || id.startsWith("compasso-"); + + // ✅ só para se for o usuário digitando/colando (evento real) + if (appState.global.isPlaying && affectsTimeline && event.isTrusted) { sendAction({ type: "STOP_PLAYBACK" }); } - }); input.addEventListener("change", (event) => { const target = event.target; @@ -450,11 +449,19 @@ document.addEventListener("DOMContentLoaded", () => { input.addEventListener("wheel", (event) => { event.preventDefault(); + + const id = event.target.id; + const affectsTimeline = id === "bars-input" || id.startsWith("compasso-"); + + // ✅ mantém o comportamento atual: mexeu em bars/compasso enquanto toca → para + if (appState.global.isPlaying && affectsTimeline) { + sendAction({ type: "STOP_PLAYBACK" }); + } + const step = event.deltaY < 0 ? 1 : -1; adjustValue(event.target, step); event.target.dispatchEvent(new Event("change", { bubbles: true })); }); - }); const buttons = document.querySelectorAll(".adjust-btn"); buttons.forEach((button) => { @@ -463,6 +470,11 @@ document.addEventListener("DOMContentLoaded", () => { const targetInput = document.getElementById(targetId); const step = parseInt(button.dataset.step, 10) || 1; if (targetInput) { + const id = targetInput.id; + const affectsTimeline = id === "bars-input" || id.startsWith("compasso-"); + if (appState.global.isPlaying && affectsTimeline) { + sendAction({ type: "STOP_PLAYBACK" }); + } adjustValue(targetInput, step); targetInput.dispatchEvent(new Event("change", { bubbles: true })); }