@abhivarde/svelte-drawer 1.0.1 → 1.0.2
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.
|
@@ -190,17 +190,14 @@
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
let contentInnerRef = $state<HTMLElement | null>(null);
|
|
193
|
+
let measuredHeight = $state<number | null>(null);
|
|
193
194
|
|
|
194
195
|
$effect(() => {
|
|
195
196
|
if (!autoHeight || !contentInnerRef) return;
|
|
196
197
|
|
|
197
198
|
const ro = new ResizeObserver((entries) => {
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const totalHeight = entry.contentRect.height;
|
|
201
|
-
const viewportH = window.innerHeight;
|
|
202
|
-
const pct = Math.max(0, ((viewportH - totalHeight) / viewportH) * 100);
|
|
203
|
-
drawer.drawerPosition.set(pct, { duration: 200 });
|
|
199
|
+
const h = entries[0]?.contentRect.height;
|
|
200
|
+
if (h) measuredHeight = h;
|
|
204
201
|
});
|
|
205
202
|
|
|
206
203
|
ro.observe(contentInnerRef);
|
|
@@ -219,7 +216,10 @@
|
|
|
219
216
|
<div
|
|
220
217
|
bind:this={contentElement}
|
|
221
218
|
class={className}
|
|
222
|
-
style="transform: {getTransform()}; z-index: 50; touch-action: none;
|
|
219
|
+
style="transform: {getTransform()}; z-index: 50; touch-action: none;{autoHeight &&
|
|
220
|
+
measuredHeight
|
|
221
|
+
? ` height: ${measuredHeight}px; transition: height 0.25s cubic-bezier(0.4,0,0.2,1);`
|
|
222
|
+
: ''}"
|
|
223
223
|
tabindex="-1"
|
|
224
224
|
role="dialog"
|
|
225
225
|
aria-modal="true"
|