I have been trying to find a light jquery parallax plugin, to do parallax with any kind of content (video, images, texts, sliders), but there was just few options and most of them just support background images and the performance was not good enough, and no fallback for old browsers not supporting translate3D. At the end, I came up with my own solution after reading and research about the current support/issues/bugs with the parallax scroll effect.
Just add a link to the css file in your
<link rel="stylesheet" href="../dist/jquery.parallux.min.css">
Then, before your closing
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script src="dist/jquery.parallux.min.js"></script>
Set the HTML scructure:
<!-- Parallax Item --> <div class="parallux"> <!-- Background layer --> <div class="parallux-bg"> <!-- Div for parallax efect --> <div class="parallux-inner"> <!-- Any HTML elements you want --> </div> </div> <!-- Parallax foreground --> </div>
Call the plugin
# Bower bower install --save parallux
|fullHeight||boolean||true||Enable/disable full page parallax. Check
|onMobile||string||scroll||Define the behavior of the plugin for mobiles. The
####Tiny and simple With ~6kb only, and just 4 options, the plugin is quite simple and straight forward
You can add all kind of content inside the background layer, it will works. I tested with videos, images (
<img> tags), videos, background, sliders (slick slider), text, and it works just fine, thanks CSS3 translate3D hardware acceleration.
Foreground and Background layers
Sometimes you may want to add some elements inside the parallax wrapper that use the normal scroll speed, so I added a layer for foreground elements and another one for the background layer (the one doing parallax effect). Check the demos and you will see what I'm talking about.
Fallback for Old Browsers
position-y will be a problem.
Fallback in Mobile
In the last version of Safari and Chrome for mobile, there is already support for translate3d! That is great, but still is not very smooth and depends a lot of the mobile hardware. For example, in Safari and iPhone 6 works great, but not in Chrome in a regular Android device, so I added an option (
enableMobile=false) and it's up to you to enable parallax on mobile devices. Works great in last versions of Chrome and Safari.
Crossbrowser issues resolved
You don't want to know how many crossbrowser issues I went trough while developing this plugin, but most of them are resolved using CSS hacks and scroll improvements, thanks to StackOverflow.
The basic structure of the project is given in the following way:
├── demos/ ├── dist/ │ ├── jquery.parallux.min.css │ ├── jquery.parallux.css │ └── jquery.parallux.min.js ├── src/ │ ├── jquery.parallux.js │ └── jquery.parallux.scss ├── .editorconfig ├── .gitignore ├── .jshintrc ├── .travis.yml ├── bower.js ├── CONTRIBUTING.md ├── gulpfile.js ├── LICENSE ├── package.json └── README.md
Contains some demos to demonstrate the plugin.
Create a pull request, issue or send me a message @TomSarduy
Apache License © Tom Sarduy