Parallax command
This command lets you create a parallax effect of different layers triggered by mouse movement.
Basic Usage (HTML)
data-jkit="[parallax:strength=3;axis=both]"
Advanced Init (JavaScript)
$('#myelement').jKit('parallax', { 'strength': '3', 'axis': 'both' });
Options
Option | Values | Default | Description |
---|---|---|---|
strength | Int | 5 | How much 3D effect to use (from 1 to 10) |
axis | “x” or “y” or “both” | x | On which axis to apply the “3D” effect |
scope | “global” or “local” | global | From which base coordinate system to calculate the mouse position and parallax effect |
detect | “mousemove” or “scroll” | mousemove | Either use the mouse position as a reference or the page scroll position |
Events
Examples
Text layers:
A simple example with three divs containing just text, animated on both axis:
Source:
<div class="parallax-container" data-jkit="[parallax:strength=2;axis=both]"> <div class="parallax parallax1">Background Layer</div> <div class="parallax parallax2">Middle Layer</div> <div class="parallax parallax3">Foreground Layer</div> </div>
Single axis:
Here’s the same example but only the x axis is affected:
Source:
<div class="parallax-container" data-jkit="[parallax:strength=2;axis=x]"> <div class="parallax parallax1">Background Layer</div> <div class="parallax parallax2">Middle Layer</div> <div class="parallax parallax3">Foreground Layer</div> </div>
Bigger sensibility:
Again the initiall example, but this time with bigger mouse sensitivity:
Source:
<div class="parallax-container" data-jkit="[parallax:strength=7;axis=both]"> <div class="parallax parallax1">Background Layer</div> <div class="parallax parallax2">Middle Layer</div> <div class="parallax parallax3">Foreground Layer</div> </div>
Local scope:
Again the initiall example, but this time we use a local scope:
Source:
<div class="parallax-container" data-jkit="[parallax:strength=2;axis=both;scope=local]"> <div class="parallax parallax1">Background Layer</div> <div class="parallax parallax2">Middle Layer</div> <div class="parallax parallax3">Foreground Layer</div> </div>
Scroll detection:
Detect the scroll position to move the different layers:
Source:
<div class="parallax-container" data-jkit="[parallax:strength=2;axis=both;detect=scroll]"> <div class="parallax parallax1">Background Layer</div> <div class="parallax parallax2">Middle Layer</div> <div class="parallax parallax3">Foreground Layer</div> </div>
Example CSS
div.parallax-container { position: relative; width: 100%; height: 250px; overflow: hidden; background: #333; } div.parallax-container div.parallax { position: absolute; top: 0px; left: 0px; width: 2500px; text-align: center; height: 250px; font-weight: bold; } .parallax1 { color: #555; font-size: 250px; line-height: 80%; } .parallax2 { color: #999; font-size: 100px; line-height: 320%; } .parallax3 { color: #fff; font-size: 50px; line-height: 760%; }
Replacements
There are currently no replacements for this command.
[ Learn more about replacements ]
Discussions
Do you have questions or do you want to suggest new features? Than head over to our new community:
[ jKit Community ]