Skip to content

Commit 5e1584a

Browse files
committed
chore: add dynamic rootMargin test to ssr
1 parent 76b5a4a commit 5e1584a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ssr/src/routes/index.svelte

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
77
let element2;
88
let intersecting2;
9+
10+
let element3;
11+
let intersecting3;
12+
13+
let rootMargin;
914
</script>
1015

1116
<h2>Basic</h2>
@@ -36,6 +41,27 @@
3641
</IntersectionObserver>
3742
</div>
3843

44+
<h2>Dynamic rootMargin</h2>
45+
46+
<div class="code-fence">
47+
<header
48+
class:intersecting={intersecting3}
49+
on:click={() => {
50+
rootMargin = rootMargin ? undefined : "-200px";
51+
}}
52+
>
53+
{intersecting3 ? "Element is in view" : "Element is not in view"}
54+
</header>
55+
56+
<IntersectionObserver
57+
element={element3}
58+
bind:intersecting={intersecting3}
59+
{rootMargin}
60+
>
61+
<div bind:this={element3}>Hello world</div>
62+
</IntersectionObserver>
63+
</div>
64+
3965
<style>
4066
h2 {
4167
margin-bottom: 1rem;

0 commit comments

Comments
 (0)