You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6c1af2c
Browse filesBrowse the repository at this point in the historyBrowse files
Fires when the element is scrolled into the viewport. Useful for [infinite scroll](/patterns/infinite-scroll).
67
+
Both use the [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options) to fire when an element enters the viewport. The only difference is that `revealed` automatically disconnects the observer after the first intersection — it fires exactly once.
-`from:<selector>` — observe a different element instead of the element itself
80
+
-[`root:<selector>`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root) — use a scrollable container as the intersection root instead of the viewport
81
+
-[`rootMargin:<value>`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin) — expand or shrink the root bounds
82
+
-[`threshold:<0–1>`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds) — minimum visible fraction before firing
Copy file name to clipboardExpand all lines: www/src/content/reference/03-events/33-intersect.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,13 @@ title: "intersect"
3
3
description: "Fires when element enters viewport"
4
4
---
5
5
6
-
The `intersect` trigger event fires when an element enters the viewport, detected via IntersectionObserver.
6
+
The `intersect` event fires when an observed element enters the viewport, detected via IntersectionObserver. It is dispatched on the observed element.
7
+
8
+
`revealed` is identical except it disconnects the observer after the first intersection, so it fires exactly once.
7
9
8
10
## When It Fires
9
11
10
-
When an element becomes visible in the viewport, used by [`hx-trigger`](/reference/attributes/hx-trigger)`="intersect"`.
12
+
Used by [`hx-trigger`](/reference/attributes/hx-trigger)`="intersect"` and `hx-trigger="revealed"`. Also fires when `from:<selector>` is used on either — the event is dispatched on the `from` element when it intersects.
11
13
12
14
## Event Detail
13
15
@@ -16,15 +18,18 @@ Empty - no additional context provided.
0 commit comments