Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Oct 8, 2024
1 parent 436c0fe commit 187c0f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
() => ref,
(v) => (ref = v)
),
onContextMenu: box.with(() => oncontextmenu),
onContextMenu: box.with(() => oncontextmenu ?? noop),
onInteractOutside: box.with(() => onInteractOutside),
onPointerDown: box.with(() => onpointerdown),
onPointerMove: box.with(() => onpointermove),
onPointerOut: box.with(() => onpointerout),
onPointerUp: box.with(() => onpointerup),
onPointerDown: box.with(() => onpointerdown ?? noop),
onPointerMove: box.with(() => onpointermove ?? noop),
onPointerOut: box.with(() => onpointerout ?? noop),
onPointerUp: box.with(() => onpointerup ?? noop),
onOpenAutoFocus: box.with(() => onOpenAutoFocus),
});
Expand Down
25 changes: 13 additions & 12 deletions packages/vaul-svelte/src/lib/vaul.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type WritableBoxedValues,
afterTick,
} from "svelte-toolbelt";
import type { MouseEventHandler, PointerEventHandler } from "svelte/elements";
import { isInput, isVertical } from "./internal/helpers/is.js";
import {
BORDER_RADIUS,
Expand Down Expand Up @@ -745,12 +746,12 @@ class DrawerOverlayState {

type DrawerContentStateProps = WithRefProps &
ReadableBoxedValues<{
onInteractOutside: (e: Event) => void;
onPointerDown: (e: PointerEvent) => void;
onPointerMove: (e: PointerEvent) => void;
onPointerUp: (e: PointerEvent) => void;
onPointerOut: (e: PointerEvent) => void;
onContextMenu: (e: MouseEvent) => void;
onInteractOutside: (e: MouseEvent | TouchEvent | PointerEvent) => void;
onPointerDown: PointerEventHandler<HTMLDivElement>;
onPointerMove: PointerEventHandler<HTMLDivElement>;
onPointerUp: PointerEventHandler<HTMLDivElement>;
onPointerOut: PointerEventHandler<HTMLDivElement>;
onContextMenu: MouseEventHandler<HTMLDivElement>;
onOpenAutoFocus: (e: Event) => void;
}>;

Expand Down Expand Up @@ -854,7 +855,7 @@ class DrawerContentState {
// }
};

onInteractOutside = (e: Event) => {
onInteractOutside = (e: MouseEvent | TouchEvent | PointerEvent) => {
this.#onInteractOutsideProp.current(e);

if (!this.#root.modal.current || e.defaultPrevented) {
Expand All @@ -873,7 +874,7 @@ class DrawerContentState {
}
};

#onpointermove = (e: PointerEvent) => {
#onpointermove: PointerEventHandler<HTMLDivElement> = (e) => {
this.lastKnownPointerEvent = e;
if (this.#root.handleOnly.current) return;
this.#onPointerMoveProp.current(e);
Expand All @@ -898,26 +899,26 @@ class DrawerContentState {
}
};

#onpointerup = (e: PointerEvent) => {
#onpointerup: PointerEventHandler<HTMLDivElement> = (e) => {
this.#onPointerUpProp.current(e);
this.pointerStart = null;
this.wasBeyondThePoint = false;
this.#root.onRelease(e);
};

#onpointerout = (e: PointerEvent) => {
#onpointerout: PointerEventHandler<HTMLDivElement> = (e) => {
this.#onPointerOutProp.current(e);
if (!this.lastKnownPointerEvent) return;
this.handleOnPointerUp(this.lastKnownPointerEvent);
};

#oncontextmenu = (e: MouseEvent) => {
#oncontextmenu: MouseEventHandler<HTMLDivElement> = (e) => {
this.#onContextMenuProp.current(e);
if (!this.lastKnownPointerEvent) return;
this.handleOnPointerUp(this.lastKnownPointerEvent);
};

#onpointerdown = (e: PointerEvent) => {
#onpointerdown: PointerEventHandler<HTMLDivElement> = (e) => {
if (this.#root.handleOnly.current) return;
this.#onPointerDownProp.current(e);
this.pointerStart = { x: e.pageX, y: e.pageY };
Expand Down

0 comments on commit 187c0f4

Please sign in to comment.