fix(player): register touchmove with passive:false via $effect
Svelte 5 has no |nonpassive modifier. Register the touchmove listener manually so e.preventDefault() can suppress page scroll during the pull-down gesture.
This commit is contained in:
@@ -31,6 +31,15 @@
|
|||||||
let isDragging = $state(false);
|
let isDragging = $state(false);
|
||||||
let dragStartY = 0;
|
let dragStartY = 0;
|
||||||
let dragStartTime = 0;
|
let dragStartTime = 0;
|
||||||
|
let overlayEl = $state<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
// Register ontouchmove with passive:false so e.preventDefault() works.
|
||||||
|
// Svelte 5 does not support the |nonpassive modifier, so we use $effect.
|
||||||
|
$effect(() => {
|
||||||
|
if (!overlayEl) return;
|
||||||
|
overlayEl.addEventListener('touchmove', onTouchMove, { passive: false });
|
||||||
|
return () => overlayEl!.removeEventListener('touchmove', onTouchMove);
|
||||||
|
});
|
||||||
|
|
||||||
function onTouchStart(e: TouchEvent) {
|
function onTouchStart(e: TouchEvent) {
|
||||||
// Don't hijack touches that start inside a scrollable element
|
// Don't hijack touches that start inside a scrollable element
|
||||||
@@ -238,6 +247,7 @@
|
|||||||
<!-- Full-screen listening mode overlay -->
|
<!-- Full-screen listening mode overlay -->
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<div
|
<div
|
||||||
|
bind:this={overlayEl}
|
||||||
class="fixed inset-0 z-60 flex flex-col overflow-hidden"
|
class="fixed inset-0 z-60 flex flex-col overflow-hidden"
|
||||||
style="
|
style="
|
||||||
background: var(--color-surface);
|
background: var(--color-surface);
|
||||||
@@ -248,7 +258,6 @@
|
|||||||
touch-action: pan-x;
|
touch-action: pan-x;
|
||||||
"
|
"
|
||||||
ontouchstart={onTouchStart}
|
ontouchstart={onTouchStart}
|
||||||
ontouchmove|nonpassive={onTouchMove}
|
|
||||||
ontouchend={onTouchEnd}
|
ontouchend={onTouchEnd}
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user