@emotionagency/parallax
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Simple and lightweight library for creating parallax effect

Instalation

npm i @emotionagency/parallax

or

yarn add @emotionagency/parallax

Usage

Basic example

import {Parallax} from '@emotionagency/parallax'

const parallax = new Parallax()

<div data-parallax="0.06"></div> // parallax power, [data-parallax] is the selector that makes the script work
<div data-parallax="0.06" data-parallax-scale="1.07"></div> // scale elem if you need
<div data-parallax="0.06" data-parallax-dir="-1"></div> // parallax direction (default is 1)

Destroy instance

import {Parallax} from '@emotionagency/parallax'

const parallax = new Parallax()

parallax.destroy()

Update nodes

import {Parallax} from '@emotionagency/parallax'

const parallax = new Parallax()

parallax.update()

Reset position

import {Parallax} from '@emotionagency/parallax'

const parallax = new Parallax()

parallax.reset()

Instance options

Option Type Default Description
inViewDetection boolean true Animation will only happen if the element is in view
mobile boolean true If true, it will work on mobile devices too.
breakpoint number 960 If mobile is selected false, then this value indicates when the parallax will be disabled.

Package Sidebar

Install

npm i @emotionagency/parallax

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

10.3 kB

Total Files

5

Last publish

Collaborators

  • lkosteckyi