Skip to main content

foundation-utils.respondtovisibility

Home > @genesislcap/foundation-utils > respondToVisibility

respondToVisibility() function​

Setup an IntersectionObserver which will activate a callback function when an element becomes visible on screen

Signature:

respondToVisibility: (element: HTMLElement, callback: (arg0: boolean) => any) => (() => void)

Parameters​

Parameter

Type

Description

element

HTMLElement

HTMLElement to observe

callback

(arg0: boolean) => any

any function called when the visibility changes

Returns:

(() => void)

A cleanup function to disconnect the observer