INSTALL
✓ Published0🌍 Public
Aabernier
Last edited Oct 13, 2020
Created on Jul 29, 2014
This example demonstrates a hardware-accelerated parallax scrolling effect. It uses jQuery and underscore.js to create a parallax layer: a background image is inserted into a div, which moves vertically at a different rate than the page scroll, controlled by an `amplitude` option. The animation leverages CSS `translate3d` transforms and a requestAnimationFrame-based scroll handler for smooth performance. A demo page shows a full-screen image scrolling over placeholder text, with the parallax effect highlighted by a red outline.
AI-generated descriptionDEPRECATED: use @abernier/parallax instead
Hardware-accelerated parallax
Demo: http://bl.ocks.org/abernier/raw/0837661e346360b5385b/
INSTALL
browser-side
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="http://underscorejs.org/underscore.js"></script>
<script src="https://cdn.rawgit.com/abernier/3225993/raw/7f928620dbe65570950ab551ee06b82e480507bb/loop.js"></script>
<script src="parallax.js"></script>
Server-side
npm install https://gist.github.com/abernier/0837661e346360b5385b/archive/847d8c07b85c0532d7a3931f90d522587cd50b85.tar.gz
Usage
$('#my').parallax({amplitude: .5});
or
var el = document.getElementById('my');
var parallax = new Parallax(el, {
amplitude: .5 // default: 1
});
parallax.loop.start();
ISC Licensed