UNPKG

@empathyco/x-components

Version:
27 lines (15 loc) 849 B
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [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.