Skip to content

React hook to read the window height Position and change the state when it is in a defined height

Notifications You must be signed in to change notification settings

aribeiro/useStick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

useStick

React hook to read the window height Position and change the state when it is in a defined height;

These hook is tinked to be used as a solution to stick header components, you can use it like this:

import {useStick} from 'useStick'

function MyComponent(){
  const [stick] = useStick(false, 900)
  
  return (
    <div className={`my-component ${stick && "stick-class"}`}>
    ...
    </div>
  )
}

When you scroll the window 900 pixels it will trigger the state change, and your stick-class will be added to the component div

About

React hook to read the window height Position and change the state when it is in a defined height

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published