@johly/vaul-svelte 1.0.0-next.8 → 1.0.0-next.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,8 @@
18
18
  onpointerup = noop,
19
19
  onpointerout = noop,
20
20
  onpointermove = noop,
21
+ ontouchmove = noop,
22
+ ontouchend = noop,
21
23
  children,
22
24
  ...restProps
23
25
  }: WithChildren<WithoutChildrenOrChild<ContentProps>> = $props();
@@ -36,6 +38,8 @@
36
38
  onpointerup: box.with(() => onpointerup ?? noop),
37
39
  onOpenAutoFocus: box.with(() => onOpenAutoFocus),
38
40
  onFocusOutside: box.with(() => onFocusOutside),
41
+ ontouchmove: box.with(() => ontouchmove ?? noop),
42
+ ontouchend: box.with(() => ontouchend ?? noop),
39
43
  });
40
44
 
41
45
  const snapPointsOffset = $state.snapshot(contentState.ctx.snapPointsOffset);
package/dist/context.d.ts CHANGED
@@ -13,6 +13,7 @@ interface DrawerContextValue extends ReadableBoxedValues<{
13
13
  handleOnly: boolean;
14
14
  container: HTMLElement | null;
15
15
  autoFocus: boolean;
16
+ nested: boolean;
16
17
  }>, WritableBoxedValues<{
17
18
  keyboardIsOpen: boolean;
18
19
  activeSnapPoint: number | string | null;
@@ -69,6 +69,10 @@ export function useDrawerContent(opts) {
69
69
  opts.onpointerdown.current?.(e);
70
70
  pointerStart = { x: e.pageX, y: e.pageY };
71
71
  ctx.onPress(e);
72
+ // Prevent parent drawer from receiving the event
73
+ if (ctx.nested.current) {
74
+ e.stopPropagation();
75
+ }
72
76
  }
73
77
  function onOpenAutoFocus(e) {
74
78
  opts.onOpenAutoFocus.current?.(e);
@@ -106,6 +110,10 @@ export function useDrawerContent(opts) {
106
110
  const isAllowedToSwipe = isDeltaInDirection(delta, ctx.direction.current, swipeStartThreshold);
107
111
  if (isAllowedToSwipe) {
108
112
  ctx.onDrag(e);
113
+ // Prevent parent drawer from receiving the drag event
114
+ if (ctx.nested.current) {
115
+ e.stopPropagation();
116
+ }
109
117
  }
110
118
  else if (Math.abs(xPosition) > swipeStartThreshold ||
111
119
  Math.abs(yPosition) > swipeStartThreshold) {
@@ -117,12 +125,20 @@ export function useDrawerContent(opts) {
117
125
  pointerStart = null;
118
126
  wasBeyondThePoint = false;
119
127
  ctx.onRelease(e);
128
+ // Prevent parent drawer from receiving the release event
129
+ if (ctx.nested.current) {
130
+ e.stopPropagation();
131
+ }
120
132
  }
121
133
  function onpointerout(e) {
122
134
  opts.onpointerout.current?.(e);
123
135
  if (e.pointerType === "touch")
124
136
  return;
125
137
  handleOnPointerUp(lastKnownPointerEvent);
138
+ // Prevent parent drawer from receiving the event
139
+ if (ctx.nested.current) {
140
+ e.stopPropagation();
141
+ }
126
142
  }
127
143
  function oncontextmenu(e) {
128
144
  opts.oncontextmenu.current?.(e);
@@ -148,12 +164,20 @@ export function useDrawerContent(opts) {
148
164
  const isAllowedToSwipe = isDeltaInDirection(delta, ctx.direction.current, swipeStartThreshold);
149
165
  if (isAllowedToSwipe) {
150
166
  ctx.onDrag(syntheticEvent);
167
+ // Prevent parent drawer from receiving the touch drag event
168
+ if (ctx.nested.current) {
169
+ e.stopPropagation();
170
+ }
151
171
  }
152
172
  }
153
- function ontouchend(_e) {
173
+ function ontouchend(e) {
154
174
  if (lastKnownPointerEvent) {
155
175
  handleOnPointerUp(lastKnownPointerEvent);
156
176
  }
177
+ // Prevent parent drawer from receiving the touch end event
178
+ if (ctx.nested.current) {
179
+ e.stopPropagation();
180
+ }
157
181
  }
158
182
  const props = $derived({
159
183
  id: opts.id.current,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johly/vaul-svelte",
3
- "version": "1.0.0-next.8",
3
+ "version": "1.0.0-next.9",
4
4
  "license": "MIT",
5
5
  "repository": "github:johanohly/vaul-svelte",
6
6
  "exports": {