1.2.1 • Published 5 years ago

lightweight-parallax v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

lightweight-parallax

| A lightweight parallax which gives you easy to use and setup mouse and scroll parallax effects

Install

npm install --save lightweight-parallax

Usage

Call the function with lwPara() or really whatever you want to call it.

To add parallax effects to an element use one of the two classes, but not both:

  • para-mouse
  • para-scroll

para-mouse

<div class="para-mouse">🚀</div>

para-mouse Options

There's two options for para-mouse that you can use to effect how the element responds:

  • data-para-size
  • data-para-dir
data-para-size

Adjusts how much the element will move, smaller equals more movement. Keep this between 1 and 10.

<div class="para-mouse" data-para-size="4">🚀</div>
data-para-dir

This is unique to the para-mouse class and will move the element in the opposite direction of the mouse.

<div class="para-mouse" data-para-dir="true">🚀</div>

para-scroll

<div class="para-scroll">🚀</div>

para-scroll Options

This takes one option:

  • data-para-size

note: this is shared between data-mouse as well but these values are unique between the two classes.

data-para-size
data-para-size

Adjusts how much the element will move, smaller equals more movement. I'd say keep this quite low, anything more than 10 and elements will be moving very slow.

<div class="para-scroll" data-para-size="2">🚀</div>

React Usage

To call the function in React use the following:

Class Component

componentDidMount() {
  lwPara()
}

Function Component

useEffect(() => lwPara())
1.2.1

5 years ago

1.1.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago