1.0.3 • Published 3 years ago

@ib-hooks/use-scroll v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@ib-hooks/use-scroll

React Hook to get X/Y coordinates of current position of the scroll.

Installation

yarn

yarn add @ib-hooks/use-scroll

npm

npm i @ib-hooks/use-scroll

Usage

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

function App() {
  const { scrollX, scrollY } = useScroll();

  return (
    <h1>
      Scroll Location: {scrollX} / {scrollY}
    </h1>
  );
}

Return

Return valueTypeDescriptionDefault value
CoordsobjectAn object containing the x, y coordinates of the current scroll position{scrollX:0, scrollY:0}