useWindowScrollPosition

About

A React hook to get the scroll position of the window

Examples

Basic Usage

import "./styles.css";
import { useWindowScrollPosition } from "rooks";

function App() {
  const position = useWindowScrollPosition(); // default config: { wait = 100, passive = true }
  console.log(position); // {x: ..., y: ...}
  return (
    <div style={{ height: 800 }}>
      <h1>Rooks : useWindowScrollPosition Example </h1>
      <br></br>

      <p>Scroll </p>
      <p> {JSON.stringify(position)} </p>
    </div>
  );
}

export default App;

Join the community!

Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!

Powered by vercel