0.1.1 • Published 2 years ago

svinohryak-hooks-lib v0.1.1

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Hooks Library

Installation

npm i svinohryak-hooks-lib

Intersection Observer Hook

Import

import { useIsOnScreen } from 'svinohryak-hooks-lib'

Features

  • Can control targetRef, rootRef, and threshold
  • Return boolean value

Using

  • at least one argument is needed
const targetRef = useRef();

const isVisible = useIsOnScreen(targetRef)
  • full control of Intersection Observer
  • default value of rootRef is null
  • default value of threshold is 0
const rootRef = useRef();
const targetRef = useRef();
const threshold = 0.6

const isVisible = useIsOnScreen(targetRef, rootRef, threshold)