We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 76b5a4a commit 5e1584aCopy full SHA for 5e1584a
ssr/src/routes/index.svelte
@@ -6,6 +6,11 @@
6
7
let element2;
8
let intersecting2;
9
+
10
+ let element3;
11
+ let intersecting3;
12
13
+ let rootMargin;
14
</script>
15
16
<h2>Basic</h2>
@@ -36,6 +41,27 @@
36
41
</IntersectionObserver>
37
42
</div>
38
43
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
39
65
<style>
40
66
h2 {
67
margin-bottom: 1rem;
0 commit comments