@abhivarde/svelte-drawer 0.0.16 → 0.0.17

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.
@@ -35,16 +35,26 @@
35
35
  document.body.style.overflow = "hidden";
36
36
 
37
37
  overlayOpacity.set(1);
38
- drawerPosition.set(0);
39
38
 
39
+ if (snapPoints && snapPoints.length > 0) {
40
+ if (activeSnapPoint === undefined) {
41
+ activeSnapPoint = snapPoints[snapPoints.length - 1];
42
+ }
43
+ const snapPos = (1 - activeSnapPoint) * 100;
44
+ drawerPosition.set(snapPos, { duration: 0 });
45
+ } else {
46
+ drawerPosition.set(0);
47
+ }
48
+ } else if (visible) {
40
49
  if (
41
50
  snapPoints &&
42
51
  snapPoints.length > 0 &&
43
- activeSnapPoint === undefined
52
+ activeSnapPoint !== undefined
44
53
  ) {
45
- activeSnapPoint = snapPoints[snapPoints.length - 1];
54
+ const currentSnapPos = (1 - activeSnapPoint) * 100;
55
+ drawerPosition.set(currentSnapPos, { duration: 0 });
46
56
  }
47
- } else if (visible) {
57
+
48
58
  overlayOpacity.set(0, { duration: 120 });
49
59
  drawerPosition.set(100, { duration: 180 });
50
60
 
@@ -64,6 +74,9 @@
64
74
  function closeDrawer() {
65
75
  open = false;
66
76
  onOpenChange?.(false);
77
+ if (snapPoints && snapPoints.length > 0) {
78
+ activeSnapPoint = undefined;
79
+ }
67
80
  }
68
81
 
69
82
  function handleKeydown(e: KeyboardEvent) {
@@ -59,7 +59,8 @@
59
59
  if (
60
60
  drawer.snapPoints &&
61
61
  drawer.activeSnapPoint !== undefined &&
62
- !dragging
62
+ !dragging &&
63
+ drawer.open
63
64
  ) {
64
65
  const snapPos = snapPointToPosition(drawer.activeSnapPoint);
65
66
  switch (drawer.direction) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhivarde/svelte-drawer",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "A drawer component for Svelte 5, inspired by Vaul",
5
5
  "author": "Abhi Varde",
6
6
  "license": "MIT",