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

parallax-image

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parallax-image

by CreativeOne

1.2.2
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Simple Parallax Script

by CreativeOne

1. Add the Styles to the <head>

<link href="https://cdn.jsdelivr.net/gh/creative-one/parallax-image@latest/styles.css" rel="stylesheet">

2. Insert the script at the end of the <body>

The script searches for all image tags with the .parallax-image class. So it has to be at the end of the code,

<script src="https://cdn.jsdelivr.net/gh/creative-one/parallax-image@latest/parallax-image.js"></script>

3. Add the .parallax-image class on your image tag

<img
    class="parallax-image"
    src="https://images.unsplash.com/photo-1646491235517-cbf731b07591?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=872&q=80"
    alt="Alt Text"
/>

To customize the speed and height of the parallax image you can add data-props

Speed example

data-speed="0" - no parallax effect

data-speed="1" - image is fixed in the viewport

you can set all values between 0 and 1. if you set larger values the image will scroll faster than the viewport.

Height example:

data-height="100vh" - fullscreen image

You can set any height value. For example px, vh, % ...

Keywords

parallax

FAQs

Package last updated on 07 Mar 2022

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