wagerfield /parallax

Parallax Engine that reacts to the orientation of a smart device

★ 16,571⑂ 2,079👁 523⑃ 46● 283▤ 11
JavaScriptNOASSERTIONCreated 2013-08-01wagerfield.github.io/parallax/
Download: v3.1v3.1 ↓3.12017-09-10
+1
Daily
16,571
stars
2,079
forks
523
watchers
46
prs
283
issues
11
releases

README

!Parallax.js



Parallax Engine that reacts to the orientation of a smart device. Where no gyroscope or motion detection hardware is available, the position of the cursor is used instead.

Check out the demo to see it in action!

 Table of Contents

- 1. Getting started
	- 1.1 Installation
	- 1.2 Preparations
	- 1.3 Run Parallax
- 2. Configuration
	- 2.1 Programmatic vs Declarative
	- 2.2 Configuration Options
- 3. Methods
- 4. Development
	- 4.1 Running the Project
	- 4.2 Opening an Issue
	- 4.3 Known Issues
- 5. FAQ
- 6. Information
   - 6.1 License
   - 6.2 Contributors

 1. Getting started

 1.1 Installation

 1.1 a) Using the CDN

1. Add  to your markup
2. Done!

Many thanks to the fine folks over at cdnjs for hosting our library.

 1.1 b) Beginners

1. Head over to the releases Section
2. Download compiled.zip from the latest release
3. Extract the ZIP archive and locate the parallax.js and parallax.min.js files
	- Use parallax.js if you want to snoop around in the code
	- Use parallax.min.js for deployment, because it has a smaller file size
4. Copy the file of your choice into your project directory
5. So far, so good!

 1.1 c) Professionals

npm i -s parallax-js

You will then find the source code in node_modules/parallax-js/src/parallax.js and the browserified, babelified, uglified, production-ready version in node_modules/parallax-js/dist/parallax.min.js

 1.2 Preparations

 Include the Script

If you use the compiled version, either downloaded from the releases page, or copied from the dist folder, include the script like any other Javascript library:  


Of course, when you've installed via npm, and use browserify/babel, you can also simply do:  
import Parallax from 'parallax-js' or  
const Parallax = require('parallax-js')

 Create your HTML elements

Each Parallax.js instance needs a container element, the scene. You're free to identify it by any means you want, but for now, let's use an ID:

html




Per default, all direct child elements of the scene will become moving objects, the layers. You can change this to a custom query selector, but again, we're going with the easiest approach for now:

html

  My first Layer!
  My second Layer!



While all other options and parameters are optional, with sane defaults, and can be set programatically, each layer needs a data-depth attribute. The movement applied to each layer will be multiplied by its depth attribute.

html

  My first Layer!
  My second Layer!



 1.3 Run Parallax

As soon as your DOM is ready and loaded, you can create a new Parallax.js instance, providing your scene element as first parameter.

javascript
var scene = document.getElementById('scene');
var parallaxInstance = new Parallax(scene);


That's it, you're running Parallax.js now!

 2. Configuration

 2.1 Programmatic vs Declarative

Most configuration settings can be declared either as data-value attribute of the scene element, or property of the configuration object. The programmatic approach will take priori

Top issues

Latest release

v3.1 v3.1 2017-09-10
v3.1 is here, featuring a vastly improved Readme and finally working npm releases again! That's right, you can now just do npm install parallax-js and be up-to-date again 🎆 

Additionally, I have those features for you:
- Breaking: added selector option, now by default all child elements of the scene will become layers, see Readme on how to restore legacy behaviour
- added hoverOnly option
- added inputElement option
- fixed bug when using deviceMotion events
- polyfilled Object.assign for IE compatibility
- added ready callback
- added destroy method
- some slight performance improv

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON