Intersection Observer
Vue Bootstrap 5 Intersection Observer
mdbIntersectionObserver
is a custom directive which allows calling a method when an element is visible on the screen.
Basic usage
Import the directive from mdb-vue-ui-kit
and add
mdbIntersectionObserver
to the
directives
object. Now you can attach the directive to
any html element or component. Check the console to see the result (F12).
If you need to call the given function not only when intersecting,
but also immediately after the directive has been inserted, use
start
modifier
If you need to call the given function only once when intersecting
and then never again, use
once
modifier
Intersection Observer - API
Import
Properties
Property | Type | Default | Description |
---|---|---|---|
container
|
Object | window |
The scroll event listener will be attached to a parent component instead of the window (default option). For this option to work, the parent node should have overflowY set to auto or scroll |
once
|
Boolean | false |
The callback will be triggered only once |
start
|
Boolean | false |
The callback will be triggered every time the element is visible and once when the directive is inserted |
lostVisibility
|
Function | null |
You can add a function that will execute when element is not visible anymore. |