1.0.1 • Published 3 years ago

@feca-hooks/use-scroll v1.0.1

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

@feca-hooks/use-scroll

React Hook to create scroll event faster and easier.

How to Install

yarn

yarn add @feca-hooks/use-scroll

npm

npm i @feca-hooks/use-scroll

Usage

Code

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

function App() {
  const onScroll = () => {
    console.log("Scrolling now.");
  };

  const { scrollX, scrollY } = useScroll(onScroll);

  return <h1>Scroll Position: { scrollX } / { scrollY }</h1>;
}

Arguments

ArgumentTypeDescriptionRequired
onScrollfunctionThe callback function executed when scroll event happens.no

Return

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

3 years ago

1.0.0

3 years ago