simplePARALLAX

the easiest way to get a parallax effect with javascript

Go down to the website content

simpleParallax is a simple and tiny JavaScript library which adds parallax animations on any images.

Where it may be laborious to get results through other plugins, simpleParallax stands out for its ease and its visual rendering. The parallax effect is directly applied on image tags, there is no need to use background images.

Any image will fit. Try it out!

simmleParallax illustration image

Installation

Simply copy/paste the below snippet just before your closing tag:

<script src="simpleParallax.js"></script>

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>

or you can install it via npm/yarn

//npm
npm install simple-parallax-js
//yarn
yarn add simple-parallax-js

simpleParallax can be import this way

import simpleParallax from 'simple-parallax-js';

Initialization

Giving the following HTML:

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

Simply add the following JavaScript code:

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

This also work with several images:

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

Settings

nametypedefaulthint
orientationstringupup - right - down - left - up left - up right - down left - left right
scaleint1.2need to be above 1.0
overflowbooleanfalse
delayint0.4the delay is in second
transitionstring'cubic-bezier(0,0,0,1)'any CSS transition
customContainerstring or nodefalsethis can be a string of directly a node

Methods

Destroy a simpleParallax instance:

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

Examples

You may want to talk about that