You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

universal-parallax

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-parallax

Easy parallax plugin using pure javascript. Also works on mobile platforms. Cross browser support.

1.0.0
Source
npmnpm
Version published
Weekly downloads
38
-64.15%
Maintainers
1
Weekly downloads
 
Created
Source

Universal Parallax

Easy parallax plugin using pure javascript. Cross browser support, including mobile platforms. See demo here

Features

  • Easy setup
  • Pure JavaScript plugin - no jQuery needed
  • Adaptive height
  • Mobile phone support

Install

$ npm install universal-parallax -S

Usage

#1

Include the script in your project.

<script src="node_modules/universal-parallax/dist/universal-parallax.min.js"></script>
#2

Include this CSS file in your project <link href="node_modules/universal-parallax/dist/universal-parallax.min.css" rel="stylesheet">

Or add this CSS

.parallax--container {
	position: absolute;
	clip: rect(0, auto, auto, 0);
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	z-index: -10;
}

.parallax {
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	/* optional */
	background-repeat: no-repeat;
	background-position: center;
	background-size: cover;
}
#3

If <section> is your container, make the parallax element inside it.

 <section>
    <div class="parallax" data-parallax-image="path/to/your_image">
 </section>

You can also use a class to define your background-image in CSS, instead of using data-parallax-image="".

#4

Fire up the JS function.

new universalParallax().init();

Custom speed

You can change the parallax speed.

// Plugin customization
new universalParallax().init({
    speed: 6.0
});

Note: speed: 1.2 is the minimum value before the background image is fixed.

Keywords

parallax

FAQs

Package last updated on 02 Jan 2018

Did you know?

Socket

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.

Install

Related posts