use-window-scroll-position

React hook to get current scroll position of the window

Usage no npm install needed!

<script type="module">
  import useWindowScrollPosition from 'https://cdn.skypack.dev/use-window-scroll-position';
</script>

README

use-window-scroll-position

package version package downloads standard-readme compliant package license make a pull request JavaScript Style Guide

React hook to get current scroll position of the window

Table of Contents

Usage

import {useWindowScrollPosition} from 'use-window-scroll-position'

const Nav = () => {
    const position = useWindowScrollPosition() // default config: { wait = 100, passive = true }
    console.log(position) // {x: ..., y: ...}
    return null
}

Install

This project uses node and npm.

$ npm install use-window-scroll-position
$ # OR
$ yarn add use-window-scroll-position

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

mit