corrigindo scroll após movimentações e edições das patterns na playlist
Deploy / Deploy (push) Successful in 2m4s
Details
Deploy / Deploy (push) Successful in 2m4s
Details
This commit is contained in:
parent
a5b5446404
commit
17e07c5838
|
|
@ -203,6 +203,13 @@ export function renderAudioEditor() {
|
|||
// --- Identifica o pai real do container ---
|
||||
const tracksParent = existingTrackContainer.parentElement;
|
||||
|
||||
// ✅ NÃO recria o container (preserva scroll e evita “voltar pro início”)
|
||||
const newTrackContainer = existingTrackContainer;
|
||||
const scrollEl = newTrackContainer;
|
||||
|
||||
// ✅ limpa apenas as lanes antigas (mantém o scroller)
|
||||
newTrackContainer.innerHTML = "";
|
||||
|
||||
// --- CRIAÇÃO E RENDERIZAÇÃO DA RÉGUA ---
|
||||
let rulerWrapper = tracksParent.querySelector(".ruler-wrapper");
|
||||
|
||||
|
|
@ -776,11 +783,16 @@ export function renderAudioEditor() {
|
|||
.forEach((g) => (g.style.width = `${widthPx}px`));
|
||||
}
|
||||
|
||||
// Sync Scroll
|
||||
// Sync Scroll (rebinding para não acumular listeners a cada render)
|
||||
newTrackContainer.addEventListener("scroll", () => {
|
||||
if (newTrackContainer.__onScroll) {
|
||||
newTrackContainer.removeEventListener("scroll", newTrackContainer.__onScroll);
|
||||
}
|
||||
|
||||
newTrackContainer.__onScroll = () => {
|
||||
const scrollPos = scrollEl.scrollLeft;
|
||||
|
||||
// ✅ guarda no estado para sobreviver a re-render
|
||||
// guarda no estado
|
||||
appState.audio.editorScrollLeft = scrollPos;
|
||||
appState.audio.editorScrollTop = scrollEl.scrollTop || 0;
|
||||
|
||||
|
|
@ -803,10 +815,17 @@ export function renderAudioEditor() {
|
|||
const rulerEl = tracksParent.querySelector(".timeline-ruler");
|
||||
appendRulerMarkers(rulerEl, currentWidth, newWidth, barWidthPx);
|
||||
}
|
||||
};
|
||||
newTrackContainer.addEventListener("scroll", newTrackContainer.__onScroll);
|
||||
});
|
||||
|
||||
// Event Listener Principal (mousedown) - rebinding
|
||||
if (newTrackContainer.__onMouseDown) {
|
||||
newTrackContainer.removeEventListener("mousedown", newTrackContainer.__onMouseDown);
|
||||
}
|
||||
|
||||
// Event Listener Principal (mousedown)
|
||||
newTrackContainer.addEventListener("mousedown", (e) => {
|
||||
newTrackContainer.__onMouseDown = (e) => {
|
||||
document.getElementById("timeline-context-menu").style.display = "none";
|
||||
document.getElementById("ruler-context-menu").style.display = "none";
|
||||
|
||||
|
|
@ -1299,10 +1318,16 @@ export function renderAudioEditor() {
|
|||
document.addEventListener("mousemove", onMouseMoveSeek);
|
||||
document.addEventListener("mouseup", onMouseUpSeek);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
newTrackContainer.addEventListener("mousedown", newTrackContainer.__onMouseDown);
|
||||
|
||||
// Menu Contexto Pista
|
||||
newTrackContainer.addEventListener("contextmenu", (e) => {
|
||||
if (newTrackContainer.__onContextMenu) {
|
||||
newTrackContainer.removeEventListener("contextmenu", newTrackContainer.__onContextMenu);
|
||||
}
|
||||
|
||||
newTrackContainer.__onContextMenu = (e) => {
|
||||
e.preventDefault();
|
||||
document.getElementById("ruler-context-menu").style.display = "none";
|
||||
const menu = document.getElementById("timeline-context-menu");
|
||||
|
|
@ -1374,7 +1399,9 @@ export function renderAudioEditor() {
|
|||
menu.style.display = "none";
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
newTrackContainer.addEventListener("contextmenu", newTrackContainer.__onContextMenu);
|
||||
|
||||
// ✅ restaura scroll após reconstruir a DOM (precisa ser após tudo estar no DOM)
|
||||
requestAnimationFrame(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue