useVisibility/useVisibility.js

reactuse · packages/core/src/bundle/src/hooks/useVisibility/useVisibility.js · javascript · MIT
ui

Module exposing: useVisibility

// Source: https://github.com/siberiacancode/reactuse | License: MIT | Copyright 2024 siberiacancode
// Provided via justclaw.it.com; keep this notice with the code.
import { useEffect, useRef, useState } from 'react';
import { isTarget } from '@/utils/helpers';
import { useRefState } from '../useRefState/useRefState';
/**
 * @name useVisibility
 * @description - Hook that gives you visibility observer state
 * @category Sensors
 * @usage medium
 *
 * @browserapi IntersectionObserver https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
 *
 * @overload
 * @param {HookTarget} target The target element to detect intersection
 * @param {boolean} [options.enabled=true] The Intersection options
 * @param {((entries: IntersectionEntry[], observer: Intersection) => void) | undefin

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key