https://github.com/samccone/scrollin
:scroll: A leak free performance focused scroll util
https://github.com/samccone/scrollin
Last synced: 8 months ago
JSON representation
:scroll: A leak free performance focused scroll util
- Host: GitHub
- URL: https://github.com/samccone/scrollin
- Owner: samccone
- License: mit
- Created: 2015-05-12T20:33:17.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-07-07T16:00:36.000Z (almost 10 years ago)
- Last Synced: 2025-03-26T09:51:11.731Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 68.4 KB
- Stars: 122
- Watchers: 6
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Scrollin
==
Do something great when an element enters the viewport.
Install
==
npm i scrollin
bower i scrollin
Use
==
```js
Scrollin.track(document.querySelector('#hi'), () => alert('hi!'))
```
Options
==
You can specify optional offset params to control when an elements is considered in the "viewport".
```js
Scrollin.track(document.querySelector('#hi'), () => alert('hi!'), {
top: 10,
right: -10,
bottom: 10,
left: 10
})
```
API
==
* `Scrollin.track(document.querySelector('#hi'), () => alert('hi!'))`
* `Scrollin.track(document.querySelectorAll('.hi'), () => alert('hi!'))`
* `Scrollin.untrackAll()`
* `Scrollin.untrack(document.querySelector('#hi'))`
* `Scrollin.checkForVisibleElements()`
* `Scrollin.getTracking()`
Dev
==
* `npm i`
* `npm run dev`
#### Building
* `npm run compile`
#### Polyfill Caveats
* You may need to polyfill `window.requestAnimationFrame`
* You may need to polyfill `Array.prototype.splice`
* You may need to polyfill `Array.prototype.some`
📜