scroll-viscosity

1.0.12 • Public • Published

Screenshot of the plugin

Viscosity

🐝 Demo 🐝

Makes an element react slower to scrolling,
like it was put into honey.

npm install --save scroll-viscosity
yarn add scroll-viscosity
import viscosity from 'scroll-viscosity'

const element = document.querySelector('#viscosity')

// with an element
let instance = viscosity(element)

// with an object
let instance = viscosity({
  element,
  easing: 0.2,
})

// with a selector
let instance = viscosity('#viscosity')

Options

Available when initializing with an object

Name type Default Description
easing {Number} 0.3 How fast the element comes back in place
wacky {Boolean} false Gives the element a random easing between .1 and .25

Hooks

instance.destroy() // remove everything related to viscosity
instance.init() // only needed after destroy() has been called
instance.restart() // restarts the application
instance.toggle() // either runs init() or destroy(), respectively

Todo:

  • Handle inline elements (calc correct w/h)
  • Don't reposition elements that's out of view
  • MutationObserver for elements entering the dom
  • Make everything event/cb based
  • Better padding/margin handling
  • Create bookmarklet for easier testing/it's cool

Known bugs:

  • slight displacement of content that comes after a row of inline-block subjects. (not prio)
  • existing advanced transforms gets placed wrong (skew/rotate)
  • when element changes 'display', it isn't updated (out of scope?)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.120latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.120
1.0.113
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.51
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i scroll-viscosity

Weekly Downloads

4

Version

1.0.12

License

ISC

Unpacked Size

26.8 kB

Total Files

13

Last publish

Collaborators

  • erikthalen