Initializes the InView
module.
Optional
props: StaticProps & MutablePropsProtected
_callbacksCallbacks instance
Protected
_destroyableStores actions that need to be executed when the module is destroyed
Protected
_elementsStores the elements being observed.
Protected
_isTracks whether the module has been destroyed
Protected
_isTracks whether this is the first time the elements are being observed.
Protected
Optional
_observerIntersection observer for detecting elements entering the viewport.
Protected
Optional
_observerIntersection observer for detecting elements leaving the viewport.
Protected
_propsCurrent properties
Retrieves the module's callbacks instance.
Returns all elements currently being observed.
Checks if the module has been destroyed.
Indicates whether the observation has started for the first time.
The name of the module, derived from the class name
Optional prefix for classnames used by the module
Current properties. Do not mutate these directly, use updateProps
instead.
Protected
_addAdds a class name on an element, and keeps track of it for removal when the module is destroyed.
The target DOM element.
The class name to toggle.
Protected
_cnHelper function to generate classnames with the module's prefix.
The class names to generate.
A string of class names with the module's prefix applied.
Protected
_destroyCleans up the module and disconnects all observers and listeners.
Protected
_getCalculates the delay before triggering an element's visibility event.
Returns default mutable properties.
Returns default static properties.
Protected
_handleHandles elements entering the viewport.
Protected
_handleToggles visibility classes and emits events for visibility changes.
Protected
_handleHandles elements leaving the viewport.
Protected
_handleHandles property mutations and updates observation events accordingly.
Protected
_removeRemoves all observation events and disconnects observers.
Protected
_setupConfigures or reconfigures the view observation events.
Protected
_setSets up IntersectionObserver
instances to detect visibility changes.
Registers an element for visibility observation.
If the element has a data-in-view-class
attribute, the specified class will be applied upon entering the viewport.
A function to stop observing the element.
Destroys the module, cleaning up resources, callbacks, and event listeners.
Adds a custom callback to the module.
The event type to listen for (e.g., 'props', 'destroy').
The function to execute when the event is triggered.
Additional settings for the callback.
Adds a callback on the module's destruction.
The function to execute during destruction.
Removes an element from observation, preventing further visibility tracking.
InView is a visibility detection utility that leverages the
IntersectionObserver
API to monitor when elements enter or leave the viewport. It provides customizable options for triggering events, delaying visibility changes, and dynamically adding CSS classes to elements based on their visibility state.Documentation