All Projects → AhmadMHawwash → scroll-sync-react

AhmadMHawwash / scroll-sync-react

Licence: MIT license
A scroll syncing library for react that is up to date

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to scroll-sync-react

Jquery Scrolllock
Locks mouse wheel scroll inside container, preventing it from propagating to parent element
Stars: ✭ 109 (+122.45%)
Mutual labels:  scrolling, scroll
Infinitescroll
Infinite Scroll (Endless Scrolling) for RecyclerView in Android
Stars: ✭ 183 (+273.47%)
Mutual labels:  scrolling, scroll
Ngx Ui Scroll
Infinite/virtual scroll for Angular
Stars: ✭ 145 (+195.92%)
Mutual labels:  scrolling, scroll
Dragscroll
micro library for drag-n-drop scrolling style
Stars: ✭ 989 (+1918.37%)
Mutual labels:  scrolling, scroll
V Bar
The virtual responsive crossbrowser scrollbar component for VueJS 2x
Stars: ✭ 216 (+340.82%)
Mutual labels:  scrolling, scroll
Pd Select
vue components ,like ios 3D picker style,vue 3d 选择器组件,3D滚轮
Stars: ✭ 101 (+106.12%)
Mutual labels:  scrolling, scroll
Scroll Js
Light cross-browser scroller that uses native javascript
Stars: ✭ 179 (+265.31%)
Mutual labels:  scrolling, scroll
Scrolldir
0 dependency JS plugin to leverage scroll direction with CSS ⬆⬇ 🔌💉
Stars: ✭ 679 (+1285.71%)
Mutual labels:  scrolling, scroll
Stickyfill
Polyfill for CSS `position: sticky`
Stars: ✭ 2,252 (+4495.92%)
Mutual labels:  scrolling, scroll
React Indiana Drag Scroll
React component which implements scrolling via holding the mouse button or touch
Stars: ✭ 190 (+287.76%)
Mutual labels:  scrolling, scroll
Android scroll endless
Scroll endless for Android recyclerview
Stars: ✭ 12 (-75.51%)
Mutual labels:  scrolling, scroll
React Scroll Sync
Synced scroll position across multiple scrollable elements
Stars: ✭ 252 (+414.29%)
Mutual labels:  sync, scroll
Fuckmyscroll.js
🔮 Animated scrolling to certain point or anchor
Stars: ✭ 10 (-79.59%)
Mutual labels:  scrolling, scroll
Prognroll
A tiny, lightweight jQuery plugin that creates scroll progress bar on the page.
Stars: ✭ 108 (+120.41%)
Mutual labels:  scrolling, scroll
Txscrolllabelview
🌭TXScrollLabelView, the best way to show & display information such as adverts / boardcast / onsale e.g. with a customView.
Stars: ✭ 714 (+1357.14%)
Mutual labels:  scrolling, scroll
Horizontal Scroll
Horizontal scroll with inertia
Stars: ✭ 175 (+257.14%)
Mutual labels:  scrolling, scroll
React Scrolllock
🔒 Prevent scroll on the <body />
Stars: ✭ 393 (+702.04%)
Mutual labels:  scrolling, scroll
Recyclerview Fastscroller
A fully customizable Fast Scroller for the RecyclerView in Android, written in Kotlin
Stars: ✭ 585 (+1093.88%)
Mutual labels:  scrolling, scroll
Scroll Snap
↯ Snap page when user stops scrolling, with a customizable configuration and a consistent cross browser behaviour
Stars: ✭ 187 (+281.63%)
Mutual labels:  scrolling, scroll
Moveto
A lightweight scroll animation javascript library without any dependency
Stars: ✭ 2,746 (+5504.08%)
Mutual labels:  scrolling, scroll

scroll-sync-react

Overview

We provide you with a React.Context.Provider (<ScrollSync/>) Component that you wrap your "context" with, and then wrap each of your scrollable elements with a scroll listner (<ScrollSyncNode/>) And see the magic happen

Note

I needed this type of functionality on a side project, so I researched and found this library https://github.com/okonet/react-scroll-sync

I have so much similarity with this library, but it's not maintained anymore, and uses the legacy context api, which introduced unexpected bugs, so I re-implemented it with the new context API and using react-hooks

codesandbox

A codesandbox that utilizes the latest of this package https://codesandbox.io/s/gallant-sky-joiou

Installation

npm i scroll-sync-react --save

Usage

import { ScrollSync, ScrollSyncNode } from './build';

const App = () =>
  <ScrollSync>
    <div style={{ display: 'flex', position: 'relative', height: 300 }}>
      <ScrollSyncNode group="a">
        <div style={{ overflow: 'auto' }}>
          <section style={{ height: 1000 }}>
            <h1>This is group `a`</h1>
            Scrollable things
          </section>
        </div>
      </ScrollSyncNode>
      <ScrollSyncNode group="a">
        <div style={{ overflow: 'auto' }}>
          <section style={{ height: 1000 }}>
            <h1>This is group `a`</h1>
            Scrollable things
          </section>
        </div>
      </ScrollSyncNode>
    </div>
  </ScrollSync>

API

ScrollSync

prop type required default description
children ReactElement true wrapper of to-be-synced elements
disabled boolean false false whether syncing is enabled or not
proportional boolean false true In case we want scroll to be proportionally applied regardless of the width and/or height

ScrollSyncNode

prop type required default description
children ReactElement true scrollable element
group string false "default" the group of scollable elements this node will be synced with
scroll "two-way", "synced-only" or "syncer-only" false "two-way" to determine scroll configuration with other ScrollSyncNodes
selfLockAxis "X", "Y", "XY" or null false null to specifiy current node scroll lock axis
onScroll (event) => void false ()=>{} on Node Scroll callback

gify example!

A photo equals a thousand word, how about a GIF! example of syncing

Todo:

  • Vertical scrolling sync
  • Providing a codesandbox
  • Configure scroll sync via scroll prop
  • Horizontal scrolling sync
  • Lock axis (locking horizontal or vertical of ScrollSyncNode)
  • Adding onScroll node callback
  • Providing tests
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].