scale-on-scroll
v1.0.0
Published
Smoothly scale an element as a function of window scroll position.
Downloads
1
Readme
#scaleOnScroll()
Smoothly scale an element as a function of window scroll position.
Installation
npm install scale-on-scroll
Usage
const scaleOnScroll = require('scale-on-scroll')
scaleOnScroll('.box',{ startOffsetElement: '.box' })
// => options
API
element
Accepts selector in the form of a string. It will be used with
document.querySelector
.
options
Accepts an object. Optional.
multiplier
defaults to0.25
, scroll position is multiplied by this number, use it to control the rate of scale change based on scrollstartOffset
defaults to0
, offsets when to start scaling based on scrollstartOffsetElement
defaults tonull
, pass a selector fordocument.querySelector
, scaling will start upon reaching that elementscaleMax
defaults to1
, set a maximum scalescaleMin
defaults to0.25
, set a minimum scalethrottleTimeout
defaults to0
, if greater than 0, throttling will be used
destroy()
#scaleOnScroll()
returns the options object. There is a destroy method on the
options object.
options.destroy()