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. Cross browser compatibility, including mobile platforms (iOS, Android). Support for opaque backgrounds.

  • 1.2.0
  • 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 compatibility, including mobile platforms (iOS, Android). Support for opaque backgrounds.

See demo

:zap: Features

  • Easy setup
  • Pure JavaScript
  • Adaptive height
  • Works on mobile devices
  • Can have opacity without affecting content

:floppy_disk: Install

$ npm i universal-parallax -S

:rocket: Setup

#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:

  • Include this in your <head> section
<link href="node_modules/universal-parallax/dist/universal-parallax.min.css" rel="stylesheet">
  • Or add this CSS
.parallax__container {
	clip: rect(0, auto, auto, 0);
	height: 100%;
	left: 0;
	overflow: hidden;
	position: absolute;
	top: 0;
	width: 100%;
	z-index: -100;
}

.parallax {
	position: fixed;
	top: 0;
	-webkit-transform: translate3d(0, 0, 0);
	transform: translate3d(0, 0, 0);
	width: 100%;

	/* BG behaviour */
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
}

:zap: BG behaviour in seperate class gives more flexibility controlling them

#3

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

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

:zap: You can also use background-image to define your image instead of using data-parallax-image=""

#4

Initialize the JS function

new universalParallax().init();

That's it! :checkered_flag:

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 is the minimum value before the background image is fixed

Opacity

Transparency can be added and it won't affect the opacity of your content.

.parallax {
	opacity: 0.5;
}

Keywords

FAQs

Package last updated on 24 Aug 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