Skip to content

Commit cfa4df3

Browse files
ultima correccion del boton de play
1 parent 9fd6f2f commit cfa4df3

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

js/ui.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,32 +200,37 @@ const VERSE_READ_DELAY = 4000; // coincide con velocidad 'normal'
200200
}, { capture: true, passive: true });
201201

202202
// ── Long-press: solo clic izquierdo (button===0) o touch ──────────────
203-
// mousedown filtra por botón; pointerdown NO filtra → causaba bugs con clic derecho
204-
const startLongPress = () => {
203+
// IMPORTANTE: stopPropagation en todos los eventos para evitar que
204+
// los handlers del contenedor de texto (que pausan el auto-play) se activen
205+
// cuando el usuario toca el botón flotante.
206+
const startLongPress = (e) => {
207+
e.stopPropagation();
205208
clearTimeout(longPressTimer);
206209
longPressTimer = setTimeout(() => {
207210
longPressTimer = null;
208211
openMenu();
209-
}, 700); // 700ms = intención clara de menú, nunca accidental
212+
}, 700);
210213
};
211-
const cancelLongPress = () => {
214+
const cancelLongPress = (e) => {
215+
if (e) e.stopPropagation();
212216
if (longPressTimer !== null) { clearTimeout(longPressTimer); longPressTimer = null; }
213217
};
214218

215-
btn.addEventListener('mousedown', (e) => { if (e.button === 0) startLongPress(); });
216-
btn.addEventListener('touchstart', startLongPress, { passive: true });
217-
btn.addEventListener('mouseup', cancelLongPress);
218-
btn.addEventListener('touchend', cancelLongPress);
219-
btn.addEventListener('mouseleave', cancelLongPress); // cancela si arrastra fuera
219+
btn.addEventListener('mousedown', (e) => { if (e.button === 0) startLongPress(e); else e.stopPropagation(); });
220+
btn.addEventListener('touchstart', (e) => startLongPress(e), { passive: true });
221+
btn.addEventListener('mouseup', (e) => cancelLongPress(e));
222+
btn.addEventListener('touchend', (e) => cancelLongPress(e));
223+
btn.addEventListener('mouseleave', (e) => cancelLongPress(e));
220224

221225
// ── Toggle play/pause ─────────────────────────────────────────────────
222-
// 'click' solo dispara para botón primario (izquierdo) — confiable en todos los dispositivos
223226
btn.addEventListener('click', (e) => {
224-
if (menuOpen) return; // el menú está abierto, ignorar clic en el botón
227+
e.stopPropagation(); // evitar que el click llegue a los handlers del contenedor
228+
if (menuOpen) return;
225229
window.toggleReadingAutoPlay();
226230
});
227231

228-
btn.addEventListener('contextmenu', (e) => e.preventDefault()); // bloquear menú del SO
232+
btn.addEventListener('contextmenu', (e) => { e.preventDefault(); e.stopPropagation(); });
233+
229234

230235

231236
})();

0 commit comments

Comments
 (0)