1.0.3 • Published 2 years ago

@emotionagency/parallax v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

OptionTypeDefaultDescription
inViewDetectionbooleantrueAnimation will only happen if the element is in view
mobilebooleantrueIf true, it will work on mobile devices too.
breakpointnumber960If mobile is selected false, then this value indicates when the parallax will be disabled.