+ {#each sections as section (section.id)}
+
{
+ section.visible = entry.isIntersecting;
+ },
+ })}
+ >
+ {section.title}
+ {section.visible ? "Visible" : "Not visible"}
+
{/each}
-
-
-{#each groupItems as item (item.id)}
-
(item.intersecting = entry.isIntersecting),
- })}
- >
- Item {item.id}
-
-{/each}
-```
-
-`root`/`rootMargin`/`threshold` configure the one shared observer, so they're passed once to `createIntersectionGroup` itself (as a function) rather than per element:
-
-```js
-const group = createIntersectionGroup(() => ({
- root: container,
- rootMargin: "0px",
- threshold: 0.5,
-}));
+
```
-Shared options are reactive: when `root`, `rootMargin`, or `threshold` changes, the group rebuilds its single shared observer and re-observes every element. Note that elements whose `once` has already fired are re-observed as well.
-
-`once`, `skip`, `onobserve`, `onintersect`, and `onexit` are the only options that make sense per element, so those are what `group.attach(...)` accepts.
-
#### Signature
```ts
@@ -433,7 +431,7 @@ function createIntersectionGroup(
#### Shared options
-Passed once to `createIntersectionGroup`; apply to every element in the group.
+Passed once to `createIntersectionGroup`. Apply to every element in the group.
| Name | Description | Type | Default value |
| :--------- | :----------------------------------------------------- | :----------------------------------------------------------------- | :------------ |
@@ -446,46 +444,24 @@ Passed once to `createIntersectionGroup`; apply to every element in the group.
Passed once per element, to `group.attach(...)`.
| Name | Description | Type | Default value |
-| :--------- | :---------------------------------------------------------- | :------------------------------------------------------- | :------------ |
+| :--------- | :-------------------------------------------------------- | :------------------------------------------------------ | :------------ |
| once | Unobserve the element after the first intersection event | `boolean` | `false` |
| skip | Skip observing this element without affecting the group | `boolean` | `false` |
| onobserve | Called when the element is first observed or when an intersection change occurs | `(entry: IntersectionObserverEntry) => void` | `undefined` |
-| onintersect | Called when the element is intersecting the viewport | `(entry: IntersectionObserverEntry) => void` | `undefined` |
+| onintersect | Called when the element is intersecting the viewport | `(entry: IntersectionObserverEntry) => void` | `undefined` |
| onexit | Called when the element stops intersecting | `(entry: IntersectionObserverEntry) => void` | `undefined` |
-#### Callbacks: `onobserve`, `onintersect`, and `onexit`
-
-Every primitive above exposes the same three callbacks, called with an [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) (components pass it directly; action and attachment dispatch it as `event.detail`):
+### SSR
-- **onobserve**: called when the element is first observed, and again on every intersection change
-- **onintersect**: called only when the element is intersecting the viewport (a filtered view of `onobserve`)
-- **onexit**: called when the element stops intersecting (transitions out of view); not called for the initial off-screen report
+All exports are SSR-safe. You do not need guards. On the server nothing is observed, so `intersecting` is `false` and `entry` is `null`. Observation starts after mount in the browser. If above-the-fold content must look correct in the server HTML, do not gate its critical rendering on `intersecting`.
-```svelte no-eval
-