All Projects → neo → react-use-scroll-position

neo / react-use-scroll-position

Licence: MIT license
A react hook to use scroll position

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to react-use-scroll-position

use-key-hook
React hook to handle all the key press.
Stars: ✭ 27 (-40%)
Mutual labels:  react-hooks, react-hook
usehooks-ts
React hook library, ready to use, written in Typescript.
Stars: ✭ 2,873 (+6284.44%)
Mutual labels:  react-hooks, react-hook
use-algolia
Dead-simple React hook to make Algolia search queries. Supports pagination out of the box.
Stars: ✭ 29 (-35.56%)
Mutual labels:  react-hooks, react-hook
veact
Mutable state enhancer library for React based on @vuejs
Stars: ✭ 62 (+37.78%)
Mutual labels:  react-hooks, react-hook
useAudioPlayer
Custom React hook & context for controlling browser audio
Stars: ✭ 176 (+291.11%)
Mutual labels:  react-hooks, react-hook
react-hooks
🎣 React Hooks to get hooked on
Stars: ✭ 53 (+17.78%)
Mutual labels:  react-hooks, react-hook
react-use-comlink
Three ways to use Comlink web workers through React Hooks (and in a typesafe manner).
Stars: ✭ 39 (-13.33%)
Mutual labels:  react-hooks, react-hook
style-hook
use css in js with react hook.
Stars: ✭ 16 (-64.44%)
Mutual labels:  react-hooks, react-hook
use-async-resource
A custom React hook for simple data fetching with React Suspense
Stars: ✭ 92 (+104.44%)
Mutual labels:  react-hooks, react-hook
react-hubspot
A collection of React hooks for interacting with Hubspot APIs
Stars: ✭ 20 (-55.56%)
Mutual labels:  react-hooks, react-hook
window-scroll-position
React hook for Window scroll position
Stars: ✭ 81 (+80%)
Mutual labels:  scroll, react-hooks
Use Http
🐶 React hook for making isomorphic http requests
Stars: ✭ 2,066 (+4491.11%)
Mutual labels:  react-hooks, react-hook
web
React hooks done right, for browser and SSR.
Stars: ✭ 940 (+1988.89%)
Mutual labels:  react-hooks, react-hook
React-Netflix-Clone
A Fully Responsive clone of Netflix website built using React.JS as a Front-end & Firebase as a Back-end.
Stars: ✭ 91 (+102.22%)
Mutual labels:  react-hooks
whatsapp-clone-react
Build a WhatsApp Clone with React JS and FireBase.
Stars: ✭ 38 (-15.56%)
Mutual labels:  react-hooks
device-orientation
React hook for the Device Orientation API
Stars: ✭ 23 (-48.89%)
Mutual labels:  react-hooks
next-qrcode
React hooks for generating QRCode for your next React apps.
Stars: ✭ 87 (+93.33%)
Mutual labels:  react-hooks
vuejs-loadmore
A pull-down refresh and pull-up loadmore scroll component for Vue.js. Vue上拉加载下拉刷新组件
Stars: ✭ 62 (+37.78%)
Mutual labels:  scroll
universalSmoothScroll
A cross-browser smooth-scrolling API which supports multiple and interruptable scroll-animations on all DOM's elements, even at the same time!
Stars: ✭ 46 (+2.22%)
Mutual labels:  scroll
react-use-hubspot-form
Embed HubSpot forms into your React components using hooks! Works with Create React App, Gatsby and other platforms.
Stars: ✭ 41 (-8.89%)
Mutual labels:  react-hooks

react-use-scroll-position

npm package

A react hook to use scroll position.

Usage

In a React functional component:

import React from 'react';
// Usually you would just need to import one of the following
import { useScrollPosition, useScrollXPosition, useScrollYPosition } from 'react-use-scroll-position';

function Example() {
  const { x, y } = useScrollPosition();
  const scrollX = useScrollXPosition();
  const scrollY = useScrollYPosition();
  return (
    <>
      <p>
        {x} should equal to {scrollX}.
      </p>
      <p>
        {y} should equal to {scrollY}.
      </p>
    </>
  );
}

In a custom React hook

import { useScrollPosition } from 'react-use-scroll-position';

function useYourImagination() {
  const { x, y } = useScrollPosition();
  return getSomethingAwesomeWith(x, y);
}

Implementation details

The scroll event handler is throttled by requestAnimationFrame.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].