
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
motion-parallax
Advanced tools
You can use npm:
npm install motion-parallax --save
and then in you js file:
const Parallax = require('motion-parallax');
Or download parallax.min.js
file and include in you document:
<script src="/path/to/parallax.min.js"></script>
<div class="parallax">
<div class="box"></div>
<div class="box"></div>
</div>
const parallax = new Parallax('.box'); // className or other selector
parallax.start();
new Parallax('className_or_other_selector', [config]);
Options can via data attributes setting:
<div class="parallax">
<div class="box" data-xrange="20" data-yrange="10"></div>
<div class="box" data-xrange="10" data-yrange="20"></div>
</div>
all config:
{
xRange: 20, // Use attribute on priority
yRange: 20,
listenElement: window,
animate: false,
invert: false,
enterCallback: function() {},
leaveCallback: function() {}
}
The above values are all defaults.
xRange, yRange
: the movable distance of an element on the X and Y axis.listenElement
: the element that listens for the mouseover event(in Mobile device is window and you can't change it).animate
: when xRange, yRange
is greater than 80 or more, you can consider opening this option.invert
: reverse direction movement.enterCallback
: mouse enter listenElement
will callback this funciton.leaveCallback
: mouse leave listenElement
will callback this funciton.include add
,remove
,refresh
.
Add a new animation element.
parallax.add(element, [config])
const parallax = new Parallax('.box');
parallax.add('.other');
parallax.add('.three');
parallax.refresh();
This api can remove alreay animate element, but you need manual call refresh
api make the operation effective.
const parallax = new Parallax('.box');
parallax.add('.other');
parallax.add('.three');
parallax.refresh();
// then you don't need className other, you can
parallax.remove('other').refresh();
const parallax = new Parallax('.box');
parallax.add('.other');
parallax.add('.three');
parallax.refresh();
// then you don't need className other and three, you can
parallax.remove('other');
parallax.remove('other');
parallax.refresh();
const parallax = new Parallax('.box');
parallax
.add('.other')
.add('.three')
.refresh();
If you have a pull request you would like to submit, please ensure that you update the minified version of the library along with your code changes.This project uses gulp
.
# dev
gulp
# min file
gulp min
FAQs
Focus on interaction, rather than just rolling parallax
The npm package motion-parallax receives a total of 0 weekly downloads. As such, motion-parallax popularity was classified as not popular.
We found that motion-parallax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.