1.0.1 • Published 4 years ago

@hoooks/use-scroll v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

@hoooks/use-scroll

Get current X, Y coordinates of scroll

Installation

yarn

yarn add @hoooks/use-scroll

npm

npm i @hoooks/use-scroll

Usage

import React from "react";
import useScroll from "@hoooks/use-scroll";

export default function App() {
  const { x, y } = useScroll();
  return (
    <div style={{ width: "300vw", height: "300vh" }}>
      <div style={{ position: "fixed" }}>
        <h1>X: {x}</h1>
        <h1>Y: {y}</h1>
      </div>
    </div>
  );
}