@abhivarde/svelte-drawer 1.0.6 → 1.0.7

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.
package/README.md CHANGED
@@ -15,6 +15,8 @@ A drawer component for Svelte 5, inspired by [Vaul](https://github.com/emilkowal
15
15
  - ✅ **Snap points** for iOS-like multi-height drawers
16
16
  - ✅ **Portal rendering** to escape z-index conflicts
17
17
  - ✅ **Optional header & footer** components for quick setup
18
+ - ✅ **Auto height** for dynamic content (AI streaming, forms, dynamic lists)
19
+ - ✅ **Configurable dismiss threshold** via `closeThreshold` prop
18
20
  - ✅ Nested drawer support
19
21
  - ✅ Scrollable content areas
20
22
  - ✅ Keyboard shortcuts (**Escape to close**, Tab navigation)
@@ -22,7 +24,6 @@ A drawer component for Svelte 5, inspired by [Vaul](https://github.com/emilkowal
22
24
  - ✅ Fully accessible with keyboard navigation
23
25
  - ✅ Full **TypeScript** support
24
26
  - ✅ Customizable styling with **Tailwind CSS**
25
- - ✅ **Auto height** for dynamic content (AI streaming, forms, dynamic lists)
26
27
 
27
28
  ## Installation
28
29
 
@@ -166,14 +167,28 @@ Add a premium blur effect to the overlay background:
166
167
  Control how far the user needs to drag before the drawer dismisses.
167
168
 
168
169
  ```svelte
170
+ <script>
171
+ import { Drawer, DrawerOverlay, DrawerContent, DrawerHandle } from '@abhivarde/svelte-drawer';
172
+
173
+ let open = $state(false);
174
+ </script>
175
+
169
176
  <!-- easier to dismiss (short drag) -->
170
177
  <Drawer bind:open closeThreshold={0.15}>
171
- ...
178
+ <DrawerOverlay class="fixed inset-0 bg-black/40" />
179
+ <DrawerContent class="fixed bottom-0 left-0 right-0 bg-white rounded-t-lg p-4">
180
+ <DrawerHandle class="mb-8" />
181
+ <p>Short drag closes this drawer.</p>
182
+ </DrawerContent>
172
183
  </Drawer>
173
184
 
174
185
  <!-- harder to dismiss (long drag required) -->
175
186
  <Drawer bind:open closeThreshold={0.5}>
176
- ...
187
+ <DrawerOverlay class="fixed inset-0 bg-black/40" />
188
+ <DrawerContent class="fixed bottom-0 left-0 right-0 bg-white rounded-t-lg p-4">
189
+ <DrawerHandle class="mb-8" />
190
+ <p>Requires a longer drag to close.</p>
191
+ </DrawerContent>
177
192
  </Drawer>
178
193
  ```
179
194
 
@@ -68,7 +68,7 @@
68
68
  }
69
69
  }
70
70
 
71
- function onPointerDown(e: PointerEvent | TouchEvent) {
71
+ function onPointerDown(e: PointerEvent) {
72
72
  const target = e.target as HTMLElement;
73
73
 
74
74
  if (
@@ -82,36 +82,24 @@
82
82
 
83
83
  startPos =
84
84
  drawer.direction === "bottom" || drawer.direction === "top"
85
- ? "clientY" in e
86
- ? e.clientY
87
- : (e.touches[0]?.clientY ?? 0)
88
- : "clientX" in e
89
- ? e.clientX
90
- : (e.touches[0]?.clientX ?? 0);
85
+ ? e.clientY
86
+ : e.clientX;
91
87
 
92
88
  startDragPos = drawer.drawerPosition.current;
93
89
 
94
90
  window.addEventListener("pointermove", onPointerMove, { passive: false });
95
91
  window.addEventListener("pointerup", onPointerUp);
96
- window.addEventListener("touchmove", onPointerMove, { passive: false });
97
- window.addEventListener("touchend", onPointerUp);
98
-
99
- e.preventDefault();
100
92
  }
101
93
 
102
- function onPointerMove(e: PointerEvent | TouchEvent) {
94
+ function onPointerMove(e: PointerEvent) {
103
95
  if (!dragging) return;
104
96
 
105
97
  e.preventDefault();
106
98
 
107
99
  const current =
108
100
  drawer.direction === "bottom" || drawer.direction === "top"
109
- ? "clientY" in e
110
- ? e.clientY
111
- : (e.touches[0]?.clientY ?? 0)
112
- : "clientX" in e
113
- ? e.clientX
114
- : (e.touches[0]?.clientX ?? 0);
101
+ ? e.clientY
102
+ : e.clientX;
115
103
 
116
104
  const delta = current - startPos;
117
105
  let newPos = startDragPos;
@@ -160,8 +148,6 @@
160
148
 
161
149
  window.removeEventListener("pointermove", onPointerMove);
162
150
  window.removeEventListener("pointerup", onPointerUp);
163
- window.removeEventListener("touchmove", onPointerMove);
164
- window.removeEventListener("touchend", onPointerUp);
165
151
  }
166
152
 
167
153
  function getFocusableElements(): HTMLElement[] {
@@ -223,7 +209,6 @@
223
209
  role="dialog"
224
210
  aria-modal="true"
225
211
  onpointerdown={onPointerDown}
226
- ontouchstart={onPointerDown}
227
212
  {...restProps}
228
213
  >
229
214
  {@render children()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhivarde/svelte-drawer",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A drawer component for Svelte 5, inspired by Vaul",
5
5
  "author": "Abhi Varde",
6
6
  "license": "MIT",
@@ -35,10 +35,10 @@
35
35
  "@sveltejs/adapter-auto": "^7.0.0",
36
36
  "@sveltejs/kit": "^2.53.0",
37
37
  "@sveltejs/package": "^2.5.7",
38
- "@sveltejs/vite-plugin-svelte": "^7.0.0",
38
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
39
39
  "publint": "^0.2.12",
40
- "svelte": "^5.46.4",
41
- "svelte-check": "^4.3.4",
40
+ "svelte": "^5.56.0",
41
+ "svelte-check": "^4.4.8",
42
42
  "typescript": "^5.9.3",
43
43
  "vite": "^8.0.0"
44
44
  },