solid-drift 0.23.0 → 0.24.0
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 +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sheet.d.ts +99 -0
- package/dist/sheet.js +219 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1473,6 +1473,39 @@ const beat = createHapticBeat(haptic, {
|
|
|
1473
1473
|
- `createHapticBeat(haptic, options?)` returns `{ playing, bpm, step, start, stop, toggle, setBpm }`. The 16-step pattern uses `"x"` for a hit, `"X"` for an accent, anything else for a rest; steps run as 16th notes at `bpm` (live-changeable via `setBpm`), the downbeat fires immediately on `start()`, and `onStep(i)` reports each step index. `hapticBeatPresets` ships `heartbeat`, `metronome`, `ticks`, and `pulse`.
|
|
1474
1474
|
- Haptics are tactile, not visual, so they fire under reduced motion too; the `enabled` switch is the way to offer quiet. Everything is a no-op where vibration is unsupported, and SSR-safe.
|
|
1475
1475
|
|
|
1476
|
+
### Bottom sheet
|
|
1477
|
+
|
|
1478
|
+
A draggable bottom sheet built on `createDrag`: the user pulls it up by a handle (or the sheet itself) and on release it springs to the nearest snap point, projected forward by the release velocity like a native sheet. Dragging below the lowest snap (or a fast downward flick) dismisses it when `dismissible`.
|
|
1479
|
+
|
|
1480
|
+
```tsx
|
|
1481
|
+
import { createBottomSheet } from "solid-drift"
|
|
1482
|
+
|
|
1483
|
+
let sheet!: HTMLDivElement
|
|
1484
|
+
let handle!: HTMLDivElement
|
|
1485
|
+
const bs = createBottomSheet(() => handle, {
|
|
1486
|
+
snapPoints: [0.4, 1], // fractions of the sheet's own height
|
|
1487
|
+
measureRef: () => sheet, // measure the sheet, not the handle
|
|
1488
|
+
onOpenChange: (open) => setScrimVisible(open),
|
|
1489
|
+
})
|
|
1490
|
+
|
|
1491
|
+
<div
|
|
1492
|
+
ref={sheet}
|
|
1493
|
+
style={{
|
|
1494
|
+
position: "fixed", left: "0", right: "0", bottom: "0",
|
|
1495
|
+
transform: `translateY(${bs.y()}px)`,
|
|
1496
|
+
}}
|
|
1497
|
+
>
|
|
1498
|
+
<div ref={handle} style={{ "touch-action": "none" }}>Handle</div>
|
|
1499
|
+
<div>Sheet content</div>
|
|
1500
|
+
</div>
|
|
1501
|
+
<button onClick={() => bs.openSheet()}>Open</button>
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
- `createBottomSheet(ref, options?)` returns `{ open, snapIndex, y, status, openSheet, close, snapTo }`. `y()` is the current translateY in pixels; `status()` is `idle`, `dragging`, or `settling`; `snapIndex()` is the snap-point index or -1 when dismissed.
|
|
1505
|
+
- `snapPoints` are visible height fractions (`1` fully open); values are clamped to [0, 1] and sorted ascending, an empty array falls back to `[1]`. Default `[0.5, 1]`; `initialSnap` (default the fullest) picks the point `openSheet()` opens at.
|
|
1506
|
+
- While the pointer is down the sheet tracks 1:1 with light rubber-banding past the fully-open top and the dismissed bottom. On release, the target is the nearest snap to `y + velocity * 0.18`; dismissal happens past the midpoint between the lowest snap and closed, or on a downward flick over 700 px/s. Snap travel uses a spring (`options.spring`, default stiffness 400 / damping 40).
|
|
1507
|
+
- Bind `ref` to the drag handle when the sheet body scrolls (keeps drag and scroll from fighting), to the sheet root otherwise. The moving element gets `translateY(y())`; the drag target needs `touch-action: none`. Starts dismissed on the server (SSR-safe); under reduced motion it jumps straight to snap targets.
|
|
1508
|
+
|
|
1476
1509
|
### Easings
|
|
1477
1510
|
|
|
1478
1511
|
Named easings: `linear`, `easeInQuad`, `easeOutQuad`, `easeInOutQuad`, `easeInCubic`, `easeOutCubic`, `easeInOutCubic`, `easeInQuart`, `easeOutQuart`, `easeInOutQuart`, `easeOutExpo`, `easeOutBack`, plus the cartoon set: `easeInBack` (anticipation dip before movement), `easeInOutBack` (wind-up, overshoot, settle), `easeOutElastic` (decaying rubber-band oscillation), `easeOutBounce` (shrinking cartoon bounces). Also `cubicBezier(x1, y1, x2, y2)` for CSS-style curves. Pass a name or a custom `(t) => number` function anywhere an easing is accepted.
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { createSlotMachine, type SlotMachineControls, type SlotMachineOptions, t
|
|
|
16
16
|
export { createStagger } from "./stagger.js";
|
|
17
17
|
export { createDebounced, createThrottled, createLocalStorage, type LocalStorageOptions, type LocalStorageControls, createMediaQuery, createClickOutside, type ClickOutsideOptions, createScrollLock, type ScrollLockControls, createInfiniteScroll, type InfiniteScrollOptions, } from "./dom.js";
|
|
18
18
|
export { createHaptic, hapticPatterns, type HapticOptions, type HapticControls, type HapticPattern, createHapticBeat, hapticBeatPresets, type HapticBeatOptions, type HapticBeatControls, } from "./haptic.js";
|
|
19
|
+
export { createBottomSheet, type BottomSheetOptions, type BottomSheetControls, } from "./sheet.js";
|
|
19
20
|
export { createHorizontalScroll, type HorizontalScrollOptions, type HorizontalScrollResult, } from "./horizontal.js";
|
|
20
21
|
export { createScrub, type ScrubKeyframe, type ScrubOptions } from "./scrub.js";
|
|
21
22
|
export { createScrollColor, type ScrollColorStop, type ScrollColorOptions, type ScrollColorFormat, createScrollTracking, type ScrollTrackingOptions, createScrollLine, type ScrollLineOptions, type ScrollLineStyle, type ScrollLineAxis, type ScrollLineOrigin, } from "./scrollfx.js";
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { createSlotMachine, createRedPacket, createConfetti, createEmojiBurst, c
|
|
|
16
16
|
export { createStagger } from "./stagger.js";
|
|
17
17
|
export { createDebounced, createThrottled, createLocalStorage, createMediaQuery, createClickOutside, createScrollLock, createInfiniteScroll, } from "./dom.js";
|
|
18
18
|
export { createHaptic, hapticPatterns, createHapticBeat, hapticBeatPresets, } from "./haptic.js";
|
|
19
|
+
export { createBottomSheet, } from "./sheet.js";
|
|
19
20
|
export { createHorizontalScroll, } from "./horizontal.js";
|
|
20
21
|
export { createScrub } from "./scrub.js";
|
|
21
22
|
export { createScrollColor, createScrollTracking, createScrollLine, } from "./scrollfx.js";
|
package/dist/sheet.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Accessor } from "solid-js";
|
|
2
|
+
import { type DragStatus } from "./gesture.js";
|
|
3
|
+
import type { SpringOptions } from "./spring.js";
|
|
4
|
+
type MaybeElement = () => Element | null | undefined;
|
|
5
|
+
export interface BottomSheetOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Snap points as fractions of the sheet's own height. `1` is fully
|
|
8
|
+
* open, `0.4` shows 40% of the sheet. Values are clamped to
|
|
9
|
+
* [0, 1] and sorted ascending; an empty array falls back to [1].
|
|
10
|
+
* Default `[0.5, 1]`.
|
|
11
|
+
*/
|
|
12
|
+
snapPoints?: number[];
|
|
13
|
+
/**
|
|
14
|
+
* Index into `snapPoints` opened by `openSheet()` with no argument.
|
|
15
|
+
* Default is the last point (fully open).
|
|
16
|
+
*/
|
|
17
|
+
initialSnap?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Dragging below the lowest snap dismisses the sheet on release.
|
|
20
|
+
* Default true.
|
|
21
|
+
*/
|
|
22
|
+
dismissible?: boolean;
|
|
23
|
+
/** Spring physics for snap animations. Default `{ stiffness: 400, damping: 40 }`. */
|
|
24
|
+
spring?: SpringOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Element used to measure the sheet height. Defaults to the drag
|
|
27
|
+
* ref. Pass the sheet root here when the drag ref is a handle, so
|
|
28
|
+
* snap fractions apply to the sheet and not the handle.
|
|
29
|
+
*/
|
|
30
|
+
measureRef?: MaybeElement;
|
|
31
|
+
/** Called when the sheet opens or closes. */
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface BottomSheetControls {
|
|
35
|
+
/** Whether the sheet is open (not dismissed). */
|
|
36
|
+
open: Accessor<boolean>;
|
|
37
|
+
/** Index into `snapPoints`, or -1 when dismissed. */
|
|
38
|
+
snapIndex: Accessor<number>;
|
|
39
|
+
/**
|
|
40
|
+
* Current translateY in pixels. Drive the sheet's transform with
|
|
41
|
+
* this: `transform: translateY(${y()}px)`.
|
|
42
|
+
*/
|
|
43
|
+
y: Accessor<number>;
|
|
44
|
+
/** `idle`, `dragging` while the pointer is down, `settling` while snapping. */
|
|
45
|
+
status: Accessor<DragStatus>;
|
|
46
|
+
/** Open the sheet at a snap point (default the fullest). */
|
|
47
|
+
openSheet: (index?: number) => void;
|
|
48
|
+
/** Dismiss the sheet below the screen. */
|
|
49
|
+
close: () => void;
|
|
50
|
+
/** Snap to a point by index (opens the sheet if dismissed). */
|
|
51
|
+
snapTo: (index: number) => void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A draggable bottom sheet built on `createDrag`.
|
|
55
|
+
*
|
|
56
|
+
* The sheet is a fixed, bottom-anchored panel the user drags by a
|
|
57
|
+
* handle (or the sheet itself). On release it snaps to the nearest
|
|
58
|
+
* snap point, projected forward by the release velocity like a
|
|
59
|
+
* native sheet; a downward drag past the lowest point (or a fast
|
|
60
|
+
* downward flick) dismisses it when `dismissible`.
|
|
61
|
+
*
|
|
62
|
+
* The drag gesture itself, pointer tracking, release velocity, and
|
|
63
|
+
* reduced-motion behavior come from `createDrag`; this primitive
|
|
64
|
+
* adds the snap-point semantics on top. While the pointer is down
|
|
65
|
+
* the sheet tracks 1:1 with light rubber-banding past the top and
|
|
66
|
+
* bottom edges; on release it springs to the chosen point.
|
|
67
|
+
*
|
|
68
|
+
* Bind the `ref` to the drag handle when the sheet body scrolls
|
|
69
|
+
* (a handle keeps drag and scroll from fighting); bind it to the
|
|
70
|
+
* sheet root for non-scrolling sheets. Either way the moving
|
|
71
|
+
* element gets `transform: translateY(${y()}px)` and the drag
|
|
72
|
+
* target gets `touch-action: none`. When the drag ref is a handle,
|
|
73
|
+
* pass the sheet root as `options.measureRef` so snap fractions
|
|
74
|
+
* are measured against the sheet.
|
|
75
|
+
*
|
|
76
|
+
* SSR-safe: starts dismissed with `y()` at 0 on the server.
|
|
77
|
+
*
|
|
78
|
+
* ```tsx
|
|
79
|
+
* let sheet!: HTMLDivElement
|
|
80
|
+
* let handle!: HTMLDivElement
|
|
81
|
+
* const bs = createBottomSheet(() => handle, {
|
|
82
|
+
* snapPoints: [0.4, 1],
|
|
83
|
+
* measureRef: () => sheet,
|
|
84
|
+
* })
|
|
85
|
+
* <div
|
|
86
|
+
* ref={sheet}
|
|
87
|
+
* style={{
|
|
88
|
+
* position: "fixed", left: "0", right: "0", bottom: "0",
|
|
89
|
+
* transform: `translateY(${bs.y()}px)`,
|
|
90
|
+
* }}
|
|
91
|
+
* >
|
|
92
|
+
* <div ref={handle} style={{ "touch-action": "none" }}>Handle</div>
|
|
93
|
+
* <div>Sheet content</div>
|
|
94
|
+
* </div>
|
|
95
|
+
* <button onClick={() => bs.openSheet()}>Open</button>
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function createBottomSheet(ref: MaybeElement, options?: BottomSheetOptions): BottomSheetControls;
|
|
99
|
+
export {};
|
package/dist/sheet.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { createEffect, createSignal, onCleanup, untrack, } from "solid-js";
|
|
2
|
+
import { now, schedule } from "./engine.js";
|
|
3
|
+
import { createDrag, } from "./gesture.js";
|
|
4
|
+
import { prefersReducedMotion } from "./reduced-motion.js";
|
|
5
|
+
/**
|
|
6
|
+
* A draggable bottom sheet built on `createDrag`.
|
|
7
|
+
*
|
|
8
|
+
* The sheet is a fixed, bottom-anchored panel the user drags by a
|
|
9
|
+
* handle (or the sheet itself). On release it snaps to the nearest
|
|
10
|
+
* snap point, projected forward by the release velocity like a
|
|
11
|
+
* native sheet; a downward drag past the lowest point (or a fast
|
|
12
|
+
* downward flick) dismisses it when `dismissible`.
|
|
13
|
+
*
|
|
14
|
+
* The drag gesture itself, pointer tracking, release velocity, and
|
|
15
|
+
* reduced-motion behavior come from `createDrag`; this primitive
|
|
16
|
+
* adds the snap-point semantics on top. While the pointer is down
|
|
17
|
+
* the sheet tracks 1:1 with light rubber-banding past the top and
|
|
18
|
+
* bottom edges; on release it springs to the chosen point.
|
|
19
|
+
*
|
|
20
|
+
* Bind the `ref` to the drag handle when the sheet body scrolls
|
|
21
|
+
* (a handle keeps drag and scroll from fighting); bind it to the
|
|
22
|
+
* sheet root for non-scrolling sheets. Either way the moving
|
|
23
|
+
* element gets `transform: translateY(${y()}px)` and the drag
|
|
24
|
+
* target gets `touch-action: none`. When the drag ref is a handle,
|
|
25
|
+
* pass the sheet root as `options.measureRef` so snap fractions
|
|
26
|
+
* are measured against the sheet.
|
|
27
|
+
*
|
|
28
|
+
* SSR-safe: starts dismissed with `y()` at 0 on the server.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* let sheet!: HTMLDivElement
|
|
32
|
+
* let handle!: HTMLDivElement
|
|
33
|
+
* const bs = createBottomSheet(() => handle, {
|
|
34
|
+
* snapPoints: [0.4, 1],
|
|
35
|
+
* measureRef: () => sheet,
|
|
36
|
+
* })
|
|
37
|
+
* <div
|
|
38
|
+
* ref={sheet}
|
|
39
|
+
* style={{
|
|
40
|
+
* position: "fixed", left: "0", right: "0", bottom: "0",
|
|
41
|
+
* transform: `translateY(${bs.y()}px)`,
|
|
42
|
+
* }}
|
|
43
|
+
* >
|
|
44
|
+
* <div ref={handle} style={{ "touch-action": "none" }}>Handle</div>
|
|
45
|
+
* <div>Sheet content</div>
|
|
46
|
+
* </div>
|
|
47
|
+
* <button onClick={() => bs.openSheet()}>Open</button>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function createBottomSheet(ref, options = {}) {
|
|
51
|
+
const { snapPoints: snapPointsOption, initialSnap: initialSnapOption, dismissible = true, spring = {}, measureRef, onOpenChange, } = options;
|
|
52
|
+
// Snap points are visible height fractions, ascending. Values are
|
|
53
|
+
// clamped to [0, 1] and sorted; an empty list falls back to [1]
|
|
54
|
+
// (a single fully-open snap).
|
|
55
|
+
const snapPoints = (snapPointsOption?.length ? [...snapPointsOption] : [1])
|
|
56
|
+
.map((p) => Math.min(1, Math.max(0, p)))
|
|
57
|
+
.sort((a, b) => a - b);
|
|
58
|
+
const initialSnap = initialSnapOption ?? snapPoints.length - 1;
|
|
59
|
+
const [open, setOpen] = createSignal(false);
|
|
60
|
+
const [snapIndex, setSnapIndex] = createSignal(-1);
|
|
61
|
+
const [y, setY] = createSignal(0);
|
|
62
|
+
const [snapping, setSnapping] = createSignal(false);
|
|
63
|
+
// Sheet height in px, measured lazily from the element.
|
|
64
|
+
let height = 0;
|
|
65
|
+
const measure = () => {
|
|
66
|
+
const el = (measureRef ?? ref)();
|
|
67
|
+
if (el && typeof el.offsetHeight === "number") {
|
|
68
|
+
const h = el.offsetHeight;
|
|
69
|
+
if (h > 0)
|
|
70
|
+
height = h;
|
|
71
|
+
}
|
|
72
|
+
return height;
|
|
73
|
+
};
|
|
74
|
+
const snapY = (index) => height * (1 - snapPoints[index]);
|
|
75
|
+
const closedY = () => height;
|
|
76
|
+
// Snap animation: the same semi-implicit Euler spring the gesture
|
|
77
|
+
// primitives use.
|
|
78
|
+
let cancelSnap = null;
|
|
79
|
+
const animateTo = (target) => {
|
|
80
|
+
cancelSnap?.();
|
|
81
|
+
cancelSnap = null;
|
|
82
|
+
if (prefersReducedMotion()) {
|
|
83
|
+
setY(target);
|
|
84
|
+
setSnapping(false);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const { stiffness = 400, damping = 40 } = spring;
|
|
88
|
+
let current = untrack(y);
|
|
89
|
+
let v = 0;
|
|
90
|
+
let last = now();
|
|
91
|
+
setSnapping(true);
|
|
92
|
+
const task = (t) => {
|
|
93
|
+
const dt = Math.min(Math.max((t - last) / 1000, 0), 0.064);
|
|
94
|
+
last = t;
|
|
95
|
+
v += (-stiffness * (current - target) - damping * v) * dt;
|
|
96
|
+
current += v * dt;
|
|
97
|
+
setY(current);
|
|
98
|
+
if (Math.abs(current - target) < 0.5 && Math.abs(v) < 20) {
|
|
99
|
+
setY(target);
|
|
100
|
+
setSnapping(false);
|
|
101
|
+
cancelSnap = null;
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
};
|
|
106
|
+
cancelSnap = schedule(task);
|
|
107
|
+
};
|
|
108
|
+
onCleanup(() => cancelSnap?.());
|
|
109
|
+
const openAt = (index) => {
|
|
110
|
+
measure();
|
|
111
|
+
const i = Math.max(0, Math.min(snapPoints.length - 1, index));
|
|
112
|
+
if (!untrack(open)) {
|
|
113
|
+
setOpen(true);
|
|
114
|
+
onOpenChange?.(true);
|
|
115
|
+
}
|
|
116
|
+
setSnapIndex(i);
|
|
117
|
+
animateTo(snapY(i));
|
|
118
|
+
};
|
|
119
|
+
const close = () => {
|
|
120
|
+
measure();
|
|
121
|
+
if (untrack(open)) {
|
|
122
|
+
setOpen(false);
|
|
123
|
+
onOpenChange?.(false);
|
|
124
|
+
}
|
|
125
|
+
setSnapIndex(-1);
|
|
126
|
+
animateTo(closedY());
|
|
127
|
+
};
|
|
128
|
+
// The underlying gesture: pointer tracking and release velocity.
|
|
129
|
+
// Its own y is only ever used as a per-grab delta source; the
|
|
130
|
+
// sheet position lives in `y` above.
|
|
131
|
+
let dragBase = 0;
|
|
132
|
+
let sheetBase = 0;
|
|
133
|
+
const settleFromRelease = (info) => {
|
|
134
|
+
measure();
|
|
135
|
+
const releaseY = untrack(y);
|
|
136
|
+
const projected = releaseY + info.velocityY * 0.18;
|
|
137
|
+
const lowest = snapY(0);
|
|
138
|
+
const dismissLine = (lowest + height) / 2;
|
|
139
|
+
if (dismissible &&
|
|
140
|
+
(projected >= dismissLine ||
|
|
141
|
+
(info.velocityY > 700 && projected > lowest))) {
|
|
142
|
+
close();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
let best = 0;
|
|
146
|
+
let bestDist = Math.abs(snapY(0) - projected);
|
|
147
|
+
for (let i = 1; i < snapPoints.length; i++) {
|
|
148
|
+
const d = Math.abs(snapY(i) - projected);
|
|
149
|
+
if (d < bestDist) {
|
|
150
|
+
bestDist = d;
|
|
151
|
+
best = i;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
openAt(best);
|
|
155
|
+
};
|
|
156
|
+
const drag = createDrag(ref, {
|
|
157
|
+
axis: "y",
|
|
158
|
+
momentum: false, // the sheet chooses its own snap target
|
|
159
|
+
onDragStart: () => {
|
|
160
|
+
cancelSnap?.();
|
|
161
|
+
cancelSnap = null;
|
|
162
|
+
setSnapping(false);
|
|
163
|
+
measure();
|
|
164
|
+
},
|
|
165
|
+
onDragEnd: settleFromRelease,
|
|
166
|
+
});
|
|
167
|
+
// 1:1 tracking while the pointer is down, with rubber-banding past
|
|
168
|
+
// the fully-open top and the dismissed bottom. The grab bases are
|
|
169
|
+
// captured on the transition into "dragging" inside this effect:
|
|
170
|
+
// writes from event handlers flush effects synchronously, so the
|
|
171
|
+
// effect runs during setStatus("dragging"), before onDragStart.
|
|
172
|
+
// Capturing here keeps the bases correct under any scheduling.
|
|
173
|
+
let prevDragStatus = "idle";
|
|
174
|
+
createEffect(() => {
|
|
175
|
+
const s = drag.status();
|
|
176
|
+
if (s === "dragging" && prevDragStatus !== "dragging") {
|
|
177
|
+
dragBase = drag.y();
|
|
178
|
+
sheetBase = untrack(y);
|
|
179
|
+
}
|
|
180
|
+
prevDragStatus = s;
|
|
181
|
+
if (s !== "dragging")
|
|
182
|
+
return;
|
|
183
|
+
const raw = sheetBase + (drag.y() - dragBase);
|
|
184
|
+
const h = height;
|
|
185
|
+
let next = raw;
|
|
186
|
+
if (next < 0)
|
|
187
|
+
next = next * 0.3;
|
|
188
|
+
else if (next > h)
|
|
189
|
+
next = h + (next - h) * 0.3;
|
|
190
|
+
setY(next);
|
|
191
|
+
});
|
|
192
|
+
const status = () => {
|
|
193
|
+
if (drag.status() === "dragging")
|
|
194
|
+
return "dragging";
|
|
195
|
+
return snapping() ? "settling" : "idle";
|
|
196
|
+
};
|
|
197
|
+
// Client-only: park the dismissed sheet below the screen once the
|
|
198
|
+
// element (and its height) exists.
|
|
199
|
+
if (typeof window !== "undefined") {
|
|
200
|
+
createEffect(() => {
|
|
201
|
+
const el = ref();
|
|
202
|
+
const mel = (measureRef ?? ref)();
|
|
203
|
+
if (!el || !mel)
|
|
204
|
+
return;
|
|
205
|
+
const h = measure();
|
|
206
|
+
if (!untrack(open) && untrack(snapIndex) === -1)
|
|
207
|
+
setY(h);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
open,
|
|
212
|
+
snapIndex,
|
|
213
|
+
y,
|
|
214
|
+
status,
|
|
215
|
+
openSheet: (index = initialSnap) => openAt(index),
|
|
216
|
+
close,
|
|
217
|
+
snapTo: openAt,
|
|
218
|
+
};
|
|
219
|
+
}
|
package/package.json
CHANGED