function observeVisibleChange(fn, node) {
    let prevVisible = null;
    const ret = new ResizeObserver(e => {
        const {width, height} = e[0].contentRect,
            visible = width !== 0 && height !== 0,
            hasChanged = visible !== prevVisible;

        if (hasChanged) {
            prevVisible = visible;
            fn(visible);
        }
    });
    ret.observe(node);
    return ret;
}
/**
 * Observe when a dom node's visibility changes.
 *
 * @param {function} fn - function that takes a single argument with visibility.
 * @param {Object} node - The DOM node to observe
 * @returns {ResizeObserver} - ResizeObserver used to implement this function.
 *      be sure to call disconnect() on this when finished.
 *
 * For a hook that conveniently wraps this function see useOnVisibleChange().
 *
 */
Observe when a dom node's visibility changes.
@param {function} fn - function that takes a single argument with visibility.
@param {Object} node - The DOM node to observe
@returns {ResizeObserver} - ResizeObserver used to implement this function.
be sure to call disconnect() on this when finished.

For a hook that conveniently wraps this function see useOnVisibleChange().
Observe when a dom node ' s visibility changes . @param { function } fn - function that takes a single argument with visibility . @param { Object } node - The DOM node to observe @returns { ResizeObserver } - ResizeObserver used to implement this function . be sure to call disconnect () on this when finished . For a hook that conveniently wraps this function see useOnVisibleChange () .
function observeVisibleChange(fn, node) {
    let prevVisible = null;
    const ret = new ResizeObserver(e => {
        const {width, height} = e[0].contentRect,
            visible = width !== 0 && height !== 0,
            hasChanged = visible !== prevVisible;
        if (hasChanged) {
            prevVisible = visible;
            fn(visible);
        }
    });
    ret.observe(node);
    return ret;
}
function observeVisibleChange ( fn , node ) { let prevVisible = null ; const ret = new ResizeObserver ( e => { const { width , height } = e [ 0 ] . contentRect , visible = width !== 0 && height !== 0 , hasChanged = visible !== prevVisible ; if ( hasChanged ) { prevVisible = visible ; fn ( visible ) ; } } ) ; ret . observe ( node ) ; return ret ; }
Observe when a dom node's visibility changes.
Observe when a dom node ' s visibility changes .