Skip to content

useSticky ​

browser
test coverage
Last changed: 15 days ago

Hook that allows you to detect that your sticky component is stuck

typescript
import { useSticky } from '@siberiacancode/reactuse';

Usage ​

typescript
const stuck  = useSticky(ref);
// or
const { stuck, ref } = useSticky();

Demo ​

Api ​

Parameters

NameTypeDefaultNote
targetHookTarget-The target sticky element
options.axis?UseStickyAxis'vertical'The axis of motion of the sticky component
options.root?UseStickyRootdocumentThe element that contains your sticky component

Parameters

NameTypeDefaultNote
options.axis?UseStickyAxis'vertical'The axis of motion of the sticky component
options.root?UseStickyRootdocumentThe element that contains your sticky component

Source ​

Source • Demo

Contributors ​

Avatardebabin

Released under the MIT License.