What is scrollEvent.js?
Simple and fast event listener for enter viewport in pure Java-Script.
Key-features are:
- Event actions for visible viewport
- Works without any dependencies
- Fast und small size in pure javascript
- Multiple instances (and events) possible
General use
- First download and add the library to the header:
With external hosted file:
- Now add ScrollEvent listener to an element:
Example and demo
Pure Java Script (Vanilla JS)
See the javascript library live in action: Open Example
It is also possible with javascript libraries like jQuery, React.js, AngularJS or vue.JS. Only have to switch element selector.
Functions
Parameter | Description |
---|---|
DOMElement | An HTML DOM element (as selector) |
Callback(element) | A function (Event), called when element is visible. Object in method: element |
Options
The options are optional and can be added as an object to the main ScrollEvent function:
Option | Description | Datatype | Default Value |
---|---|---|---|
delay | Delay time in ms, after event should fire | Number | 0 |
repetition | Amount of repetition of the event | Number | 1 |
fullyInView | Have the elemnt to be fully in view? | Boolean | false |
Example
;
Install via npm
You can simple install the javascript library locally via npm:
npm install scrolleventjs