Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/docs/src/en/plugins/intersect.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,12 @@ get a pixel value.
```alpine
<div x-intersect.margin.-100px="visible = true">...</div> // Mark as visible when element is more than 100 pixels into the viewport.
```

<a name="parent"></a>
### .parent

Allows for the underlying `IntersectionObserver` to use the viewport of the parent element, rather than the default, which is the browser.
Comment thread
joshhanley marked this conversation as resolved.

```alpine
<div x-intersect.parent="shown = true">...</div> // Mark as shown when element is moves inside it's parents viewport.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this.

```
1 change: 1 addition & 0 deletions packages/intersect/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default function (Alpine) {
let options = {
rootMargin: getRootMargin(modifiers),
threshold: getThreshold(modifiers),
root: modifiers.includes('parent') ? el.parentElement : null
}

let observer = new IntersectionObserver(entries => {
Expand Down
Loading