Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanburnette/scale-on-scroll
Smoothly scale an element as a function of window scroll position.
https://github.com/ryanburnette/scale-on-scroll
Last synced: 22 days ago
JSON representation
Smoothly scale an element as a function of window scroll position.
- Host: GitHub
- URL: https://github.com/ryanburnette/scale-on-scroll
- Owner: ryanburnette
- License: isc
- Created: 2018-03-15T02:37:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-15T05:04:41.000Z (almost 7 years ago)
- Last Synced: 2024-11-19T19:52:25.455Z (3 months ago)
- Language: JavaScript
- Homepage: https://git.io/vxLOf
- Size: 56.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# #scaleOnScroll()
Smoothly scale an element as a function of window scroll position.
## Installation
```
npm install scale-on-scroll
```## Usage
```javascript
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.```javascript
options.destroy()
```