Skip to content
/ s Public

A custom scroll event library. Vanilla JS - No dependencies.

License

Notifications You must be signed in to change notification settings

mystroken/s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏄 S

npm bundle size npm npm GitHub last commit contributions welcome

S is a JavaScript library that allows you to implement custom scroll events.
This is a fork of Bartek Drozdz VirtualScroll util and weighs ~1.5KB (minified and compressed).


🎉 Goals of the fork

  • Easier to add in a CommonJS environment
  • Enable to create several distinct instances by using a prototype rather than a singleton

Installation

npm install @mystroken/s

Usage & API

  • new S(options) Return a new instance of S. See the options below.

  • instance.on(fn) Listen to the scroll event using the specified function (fn).

  • instance.off(fn) Remove the listener.

  • instance.destroy() Will remove all events and unbind the DOM listeners.

Options

  • el: the target element for mobile touch events. Defaults to window.
  • mouseMultiplier: General multiplier for all mousewheel (including Firefox). Default to 1.
  • touchMultiplier: Mutiply the touch action by this modifier to make scroll faster than finger movement. Defaults to 2.
  • firefoxMultiplier: Firefox on Windows needs a boost, since scrolling is very slow. Defaults to 15.
  • keyStep: How many pixels to move with each key press. Defaults to 120.
  • preventTouch: If true, automatically call e.preventDefault on touchMove. Defaults to false.

About

A custom scroll event library. Vanilla JS - No dependencies.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published