1.0.0 • Published 6 years ago

scale-on-scroll v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

#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 to 0.25, scroll position is multiplied by this number, use it to control the rate of scale change based on scroll
  • startOffset defaults to 0, offsets when to start scaling based on scroll
  • startOffsetElement defaults to null, pass a selector for document.querySelector, scaling will start upon reaching that element
  • scaleMax defaults to 1, set a maximum scale
  • scaleMin defaults to 0.25, set a minimum scale
  • throttleTimeout defaults to 0, 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()