Skip to content

Commit 2567905

Browse files
authored
Update width on resize (#986)
1 parent fad2aaa commit 2567905

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/lib/holocene/pagination.svelte

+9-4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@
5454
let height: number | undefined;
5555
5656
onMount(() => {
57-
if (floatId) {
58-
width = document.getElementById(floatId)?.clientWidth;
59-
}
57+
updateWidth();
58+
6059
if (startingIndex > 0) {
6160
handlePageChange();
6261
}
@@ -70,10 +69,16 @@
7069
});
7170
};
7271
72+
const updateWidth = () => {
73+
if (floatId) {
74+
width = document.getElementById(floatId)?.clientWidth;
75+
}
76+
};
77+
7378
$: floatStyle = getFloatStyle({ width, height, screenWidth });
7479
</script>
7580

76-
<svelte:window bind:innerWidth={screenWidth} />
81+
<svelte:window bind:innerWidth={screenWidth} on:resize={updateWidth} />
7782

7883
<div class="pagination relative mb-8 flex flex-col gap-4">
7984
<div

0 commit comments

Comments
 (0)