use-scroll-sync
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

useScrollSync

Sync scroll positions between multiple elements.

Note, if the main thread is too busy or the user's battery is low, scrollbars can get out of sync.

Install

yarn add use-scroll-sync
npm install use-scroll-sync

Example

import * as React from 'react'
import { useScrollSync } from 'use-scroll-sync'

function SyncedScrollbars() {
  const headerRef = React.useRef()
  const mainRef = React.useRef()
  useScrollSync(headerRef, mainRef)
  return (
    <div>
      <header ref={headerRef}>...</header>
      <main ref={mainRef}>...</main>
    </div>
  )
}

/use-scroll-sync/

    Package Sidebar

    Install

    npm i use-scroll-sync

    Weekly Downloads

    8

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    16 kB

    Total Files

    13

    Last publish

    Collaborators

    • souporserious