Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@171h/scroll-sync

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@171h/scroll-sync

Scroll synchronization (`scroll-sync`), which associates multiple elements with scroll properties (`overflow: scroll`). When a scroll event occurs in one of the elements, the scroll effect is mapped to all the elements associated with it. To achieve synch

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Scroll Sync

Scroll synchronization (scroll-sync), which associates multiple elements with scroll properties (overflow: scroll). When a scroll event occurs in one of the elements, the scroll effect is mapped to all the elements associated with it. To achieve synchronization purposes. scroll-sync supports fixed synchronization (px) and relative synchronization (%).

Acknowledgements

This is a rewrite of scroll-sync with typescript and added some new features liking scroll-sync only by x or y.

INSTALL

npm install @171h/scroll-sync

USAGE

import ScrollSync from 'scroll-sync'

const ss = new ScrollSync({
  disabled: false, // [Boolean] Default value, allow to be empty.
  relative: true, // [Boolean] Default value, allow to be empty.
  doms: document.querySelectorAll('.scroll-container') // [Array] These elements must set scroll attributes.
})

// do sth....
// You can also find another opportunity to set related elements after instantiating the object.
ss.set(document.querySelectorAll('.scroll-container'))

// Or add or delete.
// ss.add([elements])
// ss.remove([elements])

// You can also actively clear the listener event and clear the cache.
// ss.clear()

API

.add()

// add elements to scroll-sync.

ss.add(document.documentElement)
// or use array.
ss.add(document.querySelectorAll('.other-scroll-container'))
.remove()

// remove elements to scroll-sync.

ss.remove(document.documentElement)
// or use array.
ss.remove(document.querySelectorAll('.other-scroll-container'))
.set()

// reset elements to scroll-sync.

ss.set(document.documentElement)
// or use array.
ss.set(document.querySelectorAll('.other-scroll-container'))
.clear()

// reset elements to scroll-sync.

ss.clear()

DOCUMENT

Please click here for an online experience. (中文)

FAQs

Package last updated on 28 Jun 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc