Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parallax_background

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parallax_background

VanillaJS parallax background plugin

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

parallax-background

Create captivating parallax backgrounds effortlessly with the ParallaxBackground plugin. This lightweight Vanilla JavaScript plugin, powered by GSAP animation, supports Scroll, Mouse Move, and Gyroscope events. Choose from Rotate or Shifting animations, and easily configure zoom and animation duration for a personalized touch.

Features:

  • Vanilla JavaScript and GSAP powered
  • Scroll, Mouse Move, Gyroscope events
  • Rotate or Shifting animations
  • Customizable zoom and animation duration

Demo

Basic demo
Events types and animation types demo

Package Managers

# NPM
npm install parallax_background

Installation

Include js
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
<script src="parallaxBackground.umd.js"></script>
Set HTML
<div class="parallax-background">
  <div class="parallax-inner" style="background-image: url('https://placekitten.com/1280/720')">
  </div>
</div>
Call the plugin
<script type="text/javascript">
      //Initialize with Vanilla JavaScript
      new ParallaxBackground(document.querySelector(".parallax-background"));
      //Initialize with jQuery
      $(document).ready(function() {
        $('.parallax-background').parallaxBackground();
      });
</script>
In result
<html>
  <head>
  <title>My website</title>
  </head>
  <body>

  <div class="parallax-background">
    <div class="parallax-inner" style="background-image: url('https://placekitten.com/1280/720')">
    </div>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
  //optional for jQuery initialize
  <script src="https://code.jquery.com/jquery-3.7.1.js"></script>
  <script src="parallaxBackground.umd.js"></script>

  <script type="text/javascript">
      //Initialize with Vanilla JavaScript
      new ParallaxBackground(document.querySelector(".parallax-background"));
       //Initialize with jQuery
      $(document).ready(function() {
        $('.parallax-background').parallaxBackground();
      });
  </script>

  </body>
</html>

Data Attribute Settings

In parallax-background you can add settings using the data-parallax-background attribute. You still need to call new ParallaxBackground(selector) to initialize parallax-background on the element.

Example:

<div class="parallax-background" data-parallax-background='{"duration": 3, "zoom": 30}'>
  <div class="parallax-inner" style="background-image: url('background-image.jpg')">
  </div>
</div>

Settings

OptionTypeDefault
events[SCROLL, MOUSE, GYRO][SCROLL]
animationTypeSHIFT | ROTATESHIFT
zoomint20
rotatePerspectiveint1400
animateDurationint1

Browser support

  • Chrome
  • Firefox

Dependencies

  • GSAP animation library (Version 3.10.4)

Contributing

If you'd like to get involved, please consider opening an issue or submitting a pull request. Your input is highly valued, and I'm enthusiastic about collaborating to enhance this tool.

License

parallax-background is released under the MIT License. See the LICENSE file for comprehensive details regarding the terms and conditions of use.

Keywords

FAQs

Package last updated on 15 Dec 2023

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