Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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()
```