Socket
Book a DemoInstallSign in
Socket

@artginzburg/use-scroll-sync

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@artginzburg/use-scroll-sync

Sync scroll positions between multiple elements (on both axes).

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

useScrollSync

Sync scroll positions between multiple elements.

This fork differs from the main one — it allows to also sync vertical scrolling position, in addition to horizontal, and requires first argument as the synchronization options.

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

Install

yarn add @artginzburg/use-scroll-sync
npm install @artginzburg/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({ vertical: true }, headerRef, mainRef)
  return (
    <div>
      <header ref={headerRef}>...</header>
      <main ref={mainRef}>...</main>
    </div>
  )
}

Keywords

react

FAQs

Package last updated on 01 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts