Skip to content

Commit 94d10a6

Browse files
seabeeberryKeavon
authored andcommitted
Placed PointerLock inside pointermove event handler to ensure Safari compatibility for dragging
1 parent 30e5567 commit 94d10a6

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@
325325
if (alreadyActedGuard) return;
326326
alreadyActedGuard = true;
327327
isDragging = true;
328-
beginDrag(e);
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+
335+
beginDrag();
329336
removeEventListener("pointermove", onMove);
330337
};
331338
// If it's a mouseup, we'll begin editing the text field.
@@ -340,13 +347,7 @@
340347
addEventListener("pointerup", onUp);
341348
}
342349
343-
function beginDrag(e: PointerEvent) {
344-
// Get the click target
345-
const target = e.target || undefined;
346-
if (!(target instanceof HTMLElement)) return;
347-
348-
// Enter dragging state
349-
target.requestPointerLock();
350+
function beginDrag() {
350351
initialValueBeforeDragging = value;
351352
cumulativeDragDelta = 0;
352353

0 commit comments

Comments
 (0)