simpleParallax is a very simple and lightweight jQuery plugin that improve your website with parallax animations on your 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!
Make sure jQuery library is loaded before the plugin.
Simply copy/paste the below snippet just before your closing <body>
tag:
<script src="jquery.js"></script>
<script src="simpleParallax.js"></script>
or use the below CDN link provided by jsDelivr.com
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/simple-parallax-jquery@2.4.0/src/simpleParallax.min.js"></script>
or
#npm
npm install simple-parallax-jquery
#yarn
yarn add simple-parallax-jquery
#bower
bower install simpleParallax
Giving the following HTML:
<img class="thumbnail" src="image.jpg" alt="image">
Simply add the following jQuery code:
$('.thumbnail').simpleParallax();
Find below the different settings you can apply to simpleParallax:
setting | default | |
---|---|---|
orientation | up | choose the parallax orientation effect - up, right, down or left |
scale | 1.2 | choose the scale ratio - need to be above 1.0 |
delay | 0 | add some delay for parallax animations - in second |
You can apply these settings with the following jQuery code:
$('img').simpleParallax({scale: '1.30', orientation: 'down', delay: '0.6'});
Find below the different methods you can use:
$('.thumbnail').data('simpleParallax').destroy();
-
The higher the scale setting is set, the more visible the parallax effect will be. In return, the image will lose in quality.
-
This plugin apply parallax on the image tag and not the background image. This gives you a lot of flexibility and can be added to any image.
-
You can apply simpleParallax on picture/srcset images
Open an issue or a pull request to suggest changes or additions.