Skip to content

Commit af3d4de

Browse files
seabeeberryseabeeberry
authored andcommitted
Placed PointerLock inside pointermove event handler to ensure Safari compatibility for dragging
1 parent d716dd4 commit af3d4de

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

frontend/src/components/widgets/inputs/NumberInput.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,6 @@
315315
// Don't drag the text value from is input element
316316
e.preventDefault();
317317
318-
// Get the event target and set the requestPointerLock immediately
319-
// Safari seems to require requestPointerLock() to be called directly inside the pointerdown handler instead of later in beginDrag().
320-
const target = e.target || undefined;
321-
if (!(target instanceof HTMLElement)) return;
322-
323-
target.requestPointerLock();
324-
325318
// Now we need to wait and see if the user follows this up with a mousemove or mouseup.
326319
327320
// For some reason, both events can get fired before their event listeners are removed, so we need to guard against both running.
@@ -332,6 +325,13 @@
332325
if (alreadyActedGuard) return;
333326
alreadyActedGuard = true;
334327
isDragging = true;
328+
329+
// We need to request pointer lock as immediately as possible for Safari compatibility
330+
const target = e.target || undefined;
331+
if (!(target instanceof HTMLElement)) return;
332+
333+
target.requestPointerLock();
334+
335335
beginDrag();
336336
removeEventListener("pointermove", onMove);
337337
};

0 commit comments

Comments
 (0)