corrigindo play/stop do editor de patterns

This commit is contained in:
JotaChina committed 2025-12-27 09:40:14 -03:00
1 parent 7779d293e4
commit b233164772
1 file changed
+19 -7
+19 -7
View File
@@ -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 }));
}