@empathyco/x-components
Version:
Empathy X Components
27 lines (15 loc) • 849 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [useOnDisplay](./x-components.useondisplay.md)
## useOnDisplay() function
Composable that triggers a callback whenever the provided element appears in the viewport. It can trigger the first time only or every time the element appears in the viewport.
**Signature:**
```typescript
export declare function useOnDisplay({ element, callback, triggerOnce, }: UseOnDisplayOptions): UseOnDisplayReturn;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| { element, callback, triggerOnce, } | UseOnDisplayOptions | |
**Returns:**
UseOnDisplayReturn
If the element is currently visible in the viewport or not and the watcher stop handle.