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

simple-parallax-js

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-parallax-js

simpleParallax is a simple and lightweight JS plugin that gives your website parallax animations on the images

  • 4.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.9K
increased by33.74%
Maintainers
1
Weekly downloads
 
Created
Source

simpleParallax logo

GitHub version code style: prettier

Why use simpleParallax?

simpleParallax is a very simple and lightweight Vanilla JS plugin that improve your website with parallax animations on your images.

Where it may be laborious to get results through other plugins, simpleParallax stands out for its ease and its visual rendering. The parallax effect is directly applied on image tags, there is no need to use background images.

Any image will fit. Try it out!

How to use it?

1. Install the plugin

Copy/paste

Simply copy/paste the below snippet just before your closing <body> tag:

<script src="simpleParallax.js"></script>

or use the below CDN link provided by jsDelivr.com

<script src="https://cdn.jsdelivr.net/npm/simple-parallax-js@4.1.0/dist/simpleParallax.min.js"></script>

or

Module

#npm
npm install simple-parallax-js

#yarn
yarn add simple-parallax-js

Then you can simply import it:

import simpleParallax from 'simple-parallax-js';

2. Initialize the plugin

Giving the following HTML:

<img class="thumbnail" src="image.jpg" alt="image">

Simply add the following JS code:

var images = document.getElementsByClassName('thumbnail');
var instances = new simpleParallax(images);
// or
var instance = new simpleParallax(images[0]);

3. Settings

Find below the different settings you can apply to simpleParallax:

settingdefault
delay0.6add some delay for parallax animations - in second
orientationupchoose the parallax orientation effect - up, right, down or left
scale1.2choose the scale ratio - need to be above 1.0
overflowfalseby default, the image is scaled to apply a parallax effect without any overflow on the original image container. If overflow is set to true, the image will be translated out of its natural flow without any scale.
transitioncubic-bezier(0,0,0,1)choose the css transition (will work only if delay is different that 0) - ease, linear, ease-in, etc.
breakpointfalsechoose the minimum breakpoint (in pixel) where simpleParallax will be initialized - 768

You can apply these settings with the following JS code:

var images = document.querySelectorAll('.thumbnail');
new simpleParallax(images, {
    delay: 0, 
    orientation: 'down', 
    scale: 1.30, 
    overfow: true 
});

3. Methods

Destroy

destroy a single instance

instance.destroy();

destroy several instances

instances.forEach(instance => instance.destroy());

Good to know

  • The higher the scale setting is set, the more visible the parallax effect will be. In return, the image will lose in quality (no loss of quality if overlow option is set to false)

  • This plugin apply parallax on the image tag and not the background image. This gives you a lot of flexibility and can be added to any image.

  • You can apply simpleParallax on picture/srcset images

Author

Geoffrey Signorato

Contributing

Open an issue or a pull request to suggest changes or additions.

Keywords

FAQs

Package last updated on 01 Mar 2019

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