Visiblee is a a tiny Typescript utility library for triggering a callback when the element comes into view. It's designed to be lightweight and performant.
npm install visiblee``;
import { Visiblee } from 'visiblee
Visiblee.watch(element, (entry) => {
console.log('I am visible');
});
``
* elements: Array - The elements to watch.callback: (entry: Visiblee.Entry) => void
* - The callback to execute when it bcomes visible.triggerPoint: number = 0.5
* - The percentage point of the viewport for the callback to trigger.removeOnceVisible: boolean = true
* - Whether to remove the element from the watch list once it's visible.``
Visiblee.watch(element, (entry) => {
console.log('I am visible');
}, 0.5, true);
* element: HTMLElement - The element to remove``
Visiblee.unwatch(element);
- The elements to watch.
* triggerPoint: number = 0.5 - The percentage point of the viewport for the callback to trigger.
`
Visiblee.check(element, 0.5)
`$3
Returns the Visiblee instance.`
Visiblee.getInstance();
``