1.4.4 • Published 3 years ago

@sichangi/virtual-scroll v1.4.4

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

virtual-scroll

pipeline status

Custom scroll event with inertia/momentum, touch and keyboard compatible.

See this article for the original authors description.

Goals of the fork

  • Support browser and commonjs environments
  • Add SSR environment support
  • Provide an example usage

Installation

yarn add @sichangi/virtual-scroll

Usage & API

Return a new instance of VirtualScroll. See the options below.

const instance = new VirtualScroll(options)

Listen to the scroll event using the specified function (fn) and optional context.

instance.on(fn, context)

Remove the listener.

instance.off(fn, context)

Will remove all events and unbind the DOM listeners.

instance.destroy()

Events note: Each instance will listen only once to any DOM listener.These listener are enabled/disabled automatically. However, it's a good practice to always call destroy() on your VirtualScroll instance, especially if you are working with a SPA.

Options

namedefaultdescription
elwindowthe target element for mobile touch events
mouseMultiplier1General multiplier for all mousewheel (including Firefox)
touchMultiplier2Mutiply the touch action by this modifier to make scroll faster than finger movement.
firefoxMultiplier15Firefox on Windows needs a boost, since scrolling is very slow.
keyStep120How many pixels to move with each key press.
preventTouchfalseIf true, automatically call e.preventDefault on touchMove.
unpreventTouchClassvs-touchmove-allowedElements with this class won't preventDefault on touchMove. For instance, useful for a scrolling text inside a VirtualScroll-controled element.
limitInertiafalseif true, will leverage Lethargy to avoid everlasting scroll events (mostly on Apple Mouse, Trackpad, and free-wheel mouse).
passiveundefinedif used, will use passive events declaration for the wheel and touch listeners. Can be true or false.
disableUserInputfalseif true, does not listen for scroll events

License

MIT.

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.0

4 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago