Parallax
Straight-forward parallax scrolling background images as an ES6 module.
Features
- Easily import as an ES6 module
- Plain old JavaScript; no jQuery
- Simple as heck and really tiny
- Looks pretty cool
Usage
- Install Parallax with npm:
npm install --save parallax-scroll
- Import the
parallax
function:
;
Alternatively, an old-school require()
will work:
var parallax = ;
- Create a new instance of
Parallax
, passing the constructor a selector, DOM element, or array of DOM elements, and optionally a hash of options, and then call theanimate()
function on the resulting object:
const parallax = '.js-parallax' speed: 02 // Anything over 0.5 looks silly; parallax;
- Write some markup for your parallax elements:
- As well as some structural CSS: