In View
Reacts when its content scrolls into view: reveal it, load more, or pause it when it leaves.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
threshold | number | 0 | How much of it must show to count as in view, from 0 (any of it) to 1 (all of it). |
root-margin | string | 0px | Grows or shrinks the viewport, as CSS margins ("200px", "0px 0px -20% 0px"). |
once | boolean | false | Stops watching after the first entry. |
disabled | boolean | false | Stops watching. |
Slots
| Name | Description |
|---|---|
(default) | The content that is watched. |
Events
| Name | Type | Description |
|---|---|---|
enter | CustomEvent<{ ratio: number }> | Fired when it comes into view. Does not bubble. |
leave | CustomEvent<{ ratio: number }> | Fired when it goes out of view. Does not bubble. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-in-view--transition-duration | duration | 500ms | |
--c2-in-view--transition-timing-function | easing | cubic-bezier(0.2, 0.7, 0.2, 1) | |
--c2-in-view--transition-delay | duration | 0ms | Staggers a row of reveals. |
--c2-in-view__hidden--opacity | opacity | 1 | The content's opacity while out of view: 0 makes it fade in. |
--c2-in-view__hidden--transform | transform | none | Its transform while out of view (translateY(16px), scale(0.96)). |