/b-scroll-lock

Primary LanguageJavaScriptMIT LicenseMIT

Bornfight

b-scroll-lock [all b- libs]

Bornfight Studio frontend micro lib for locking and unlocking the scroll

GitHub package.json version GitHub package.json dynamic GitHub issues GitHub

📦 Getting Started

  • install b-scroll-lock trough npm or pull ti from git
npm i @bornfight/b-scroll-lock
  • include b-lib to your JS after running npm install

🔨️ Usage

JS
import ScrollLock from "@bornfight/b-scroll-lock";
Usage tips
  • class contains two methods, one for lock scroll and one for unlock
  • every method has one property that could be passed

💎 Customization

const scrollLock = new ScrollLock();

// value 100 represent on witch scroll value will "is-fixed-scrolled" class be added to body
// offset value (100) is optional and default is 100
scrollLock.lockScroll(100);

// value 100 represent on witch scroll value will document be after scroll is unlocked
// offset value (100) is optiona and default is scroll value before locking the scroll
scrollLock.unlockScroll(100);

🚀 Useful to know

  1. if used with page transition - don't forget to unlock scroll
  2. will not work for scroll inside modal/popup

📦 Contribute

Gulp based system

npm run dev - dev environent with browsersync

License

MIT © Bornfight Studio