use-sync-scroll-hook
v0.0.3
Published
React hook to synchronise the scroll position of multiple containers.
Downloads
370
Readme
use-sync-scroll-hook
React hook to synchronise the scroll position of multiple containers.
Demo
https://slocka.github.io/use-sync-scroll-hook/
Install
npm install --save use-sync-scroll-hook
or
yarn add use-sync-scroll-hook
Usage
import React, { useRef } from 'react'
import useSyncScroll from 'use-sync-scroll-hook'
export default function Example() {
const headerRef = useRef()
const bodyRef = useRef()
useSyncScroll([headerRef, bodyRef])
return (
<div className="table">
<div ref={headerRef} className="table-header">
...
</div>
<div ref={bodyRef} className="table-body">
...
</div>
</div>
)
}
License
MIT © slocka