UNPKG

@empathyco/x-components

Version:
55 lines (26 loc) 980 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 <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> { element, callback, triggerOnce, } </td><td> UseOnDisplayOptions </td><td> </td></tr> </tbody></table> **Returns:** UseOnDisplayReturn If the element is currently visible in the viewport or not and the watcher stop handle.