<WAIntersectionObserver>
@ChildContent
</WAIntersectionObserver>Tracks immediate child elements and fires events as they move in and out of view.
| Property | Type | Default | Description |
|---|---|---|---|
| Disabled | bool | false | If true, disables the intersection observer functionality. |
| IntersectClass | string | CSS class applied to elements when they intersect the viewport. | |
| RootElementId | string | Element ID to define the viewport boundaries for tracked targets. | |
| ShowOnce | bool | false | If enabled, observation ceases after initial intersection. |
| RootMargin | string | 0px | Offset space around the root boundary. Accepts values like CSS margin syntax. |
| Threshold | string | 0 | One or more space-separated values representing visibility percentages that trigger the observer callback. |
| Event Name | Description |
|---|---|
| Intersecting | Fired when a tracked element begins intersecting. |
| Leaving | Fired when a tracked element ceases intersecting. |
Threshold = 1 requires the box to be entirely in view before OnIntersecting triggers.
<div class="wa-stack wa-gap-xl" style="max-width:320px;">
<div style="height: 400px;">
Scroll down to see the box change.
</div>
<WAIntersectionObserver
Threshold="1"
Intersecting="UpdateMessageIntersecting"
Leaving="UpdateMessageLeaving">
<div class="box">
@message
</div>
</WAIntersectionObserver>
<div style="height: 400px;">
</div>
</div>
@code {
string message { get; set; } = "Waiting to be completely in view...";
void UpdateMessageIntersecting()
{
message = "The box is now in view!";
}
void UpdateMessageLeaving()
{
message = "Waiting to be completely in view...";
}
}