parallax-element.js
jQuery plugin that creates parallax effect for specific element.
Usage and Defaults
The scroll animation speed is based upon either a data-speed
attribute in a html tag or the defaultSpeed
option.
The speed value (integer) should be kept between -1
and 1
.
A positive number makes the element appear to scroll slowly downward, while a negative integer makes the element appear to scroll slowly upward.
Javascript file:
$('.element').parallaxElement();
$('.element').parallaxElement({
defaultSpeed: 0.2,
useOffset: true,
defaultOffset: 200,
disableMobile: false,
minWidth: false
});
To assign different speeds to indivudual elements, use the data-speed
attribute in html:
<div class="element" data-speed="0.1">
</div>
<div class="element" data-speed="0.2">
</div>
<div class="element" data-speed="-0.1">
</div>
Browserify
Make sure to shim jQuery and then simply require the file:
require('parallax-element');
$('.element').parallaxElement({
defaultSpeed: 0.1
});