Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 and opacity support.

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59
increased by11.32%
Maintainers
1
Weekly downloads
 
Created
Source

Universal Parallax

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

See demo

:zap: Features

  • Easy setup
  • Pure JavaScript plugin - no jQuery needed
  • Adaptive height
  • Mobile phone support
  • Support for transparent backgrounds - without affecting content

:floppy_disk: Install

$ npm i universal-parallax -S

:rocket: Usage

#1

Include the script at the bottom of your project

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

Choose between either..

  • Including this in your <head> section
<link href="node_modules/universal-parallax/dist/universal-parallax.min.css" rel="stylesheet">
  • Or adding this CSS
    :zap: Gives more flexibility controlling the behaviour of bg images (see "optional" comment)
.parallax--container {
	position: absolute;
	clip: rect(0, auto, auto, 0);
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	z-index: -10; /* place further back if necessary */
}

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

If <section> is your container, make the parallax element inside it, just before the closing tag :fire:

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

:zap: 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();
#5

That's it! :checkered_flag:

  • If it resembles the demo - you're done :tada:
  • See customizations underneath
  • Please report any problems you find, or requests for new features and improvements. Thanks! :heart:

Custom speed

You can change the parallax speed; the higher the number, the slower the parallax effect

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

:zap: speed: 1.2 is the minimum value before the background image is fixed

Opacity

If desired, transparency can be added to the parallax elements with CSS and it won't affect the opacity of your content above. CSS class not included* :smirk:

.parallax--opacity {
	opacity: 0.5;
}

Keywords

FAQs

Package last updated on 02 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc