SimpleParallax is very and simple lightweight JavaScript plugin for parallax image animations. It can convert any images to parallax animation within the website, there is no need to use any background images.

Features:

Install with NPM

$ npm install simple-parallax-js

Install with Yarn

$ yarn add simple-parallax-js

How to use it:

1. Include the Javascript simpleParallax.min.js at the bottom of the web page.

<script src="path/to/simpleParallax.min.js"></script>

2. or use the below CDN link provided by jsDelivr.com:

<script src="https://cdn.jsdelivr.net/npm/simple-parallax-js@5.2.0/dist/simpleParallax.min.js"></script>

3. Add the basic HTML to the page.

<img class="thumbnail" src="image.jpg" alt="image">

4. Initialize the plugin and we're ready to go.

var image = document.getElementsByClassName('thumbnail');
new simpleParallax(image);

5. Initialize the plugin with several images:

var images = document.querySelectorAll('img');
new simpleParallax(images);

Plugin's default options:

Setting Type Default Hint
orientation string up up - right - down - left - up left - up right - down left - down right
scale int 1.3 need to be above 1.0
overflow boolean false
delay int 0.4 the delay is in second
transition string false any CSS transition
customContainer string or node false this can be a string of directly a node

Default Parallax

image

HTML structure

<img class="thumbnail" src="path/to/demo-3.jpg" alt="image">

Script

var image = document.getElementsByClassName('thumbnail');
new simpleParallax(image, {
  scale: 1.4,
});

Orientation based parallax

image

HTML structure

<img class="thumbnail2" src="path/to/demo-3.jpg" alt="image">

Script

var image2 = document.getElementsByClassName('thumbnail2');
new simpleParallax(image2, {
  scale: 1.4,
  orientation: 'right'
});

Overflow Parallax

image

HTML structure

<img class="thumbnail3" src="path/to/demo-3.jpg" alt="image">

Script

var image3 = document.getElementsByClassName('thumbnail3');
new simpleParallax(image3, {
  scale: 1.4,
  orientation: 'left',
  overflow: true
});