```
This also works on components:
```html
```
The function will be called whenever the visiblity of the element changes with the argument being a boolean (`true` means the element is visible on the page, `false` means that it is not).
The second argument is the corresponding [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) object.
```javascript
visibilityChanged (isVisible, entry) {
this.isVisible = isVisible
console.log(entry)
}
```
## IntersectionObserver options
It's possible to pass the [IntersectionObserver `options` object](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#Parameters) using the `intersection` attribute:
```html
```
## Once
It can be useful to listen for when the element is visible only once, for example to build introduction animations. Set the `once` option to `true`:
```html
```
## Throttling visibility
You can use the `throttle` options (in ms) specifying minimal state duration after which an event will be fired. It's useful when you are tracking visibility while scrolling and don't want events from fastly scrolled out elements.
```html
```
You can also pass a `leading` option to trigger the callback the first time when the visibility changes without waiting for the throttle delay.
I can either be `visible`, `hidden` or `both`.
```html
```
## Passing custom arguments
You can add custom argument by using an intermediate function:
```html
```
Here `visibilityChanged` will be call with a third custom argument `customArgument`.
## Disabling the observer
Passing a falsy value to the directive will disable the observer:
```html
```
# Example
```html
```
---
## License
[MIT](http://opensource.org/licenses/MIT)