2.1.0 • Published 3 years ago

parallaxjs v2.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

parallaxjs

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Simple Parallax on DOM elements.

paypal coinbase twitter

npm.io

Installation

npm install parallaxjs

Usage

<div class="layer" data-parallax-speed="3">Parallax layer</div>
<div class="layer" data-parallax-speed="1.5">Other layer that moves faster</div>
import Parallax from "parallaxjs";
const parallax = new Parallax(document.querySelectorAll(".layer"));

// Add parallax handlers to your own listeners (so that you can debounced them or whatever)
window.addEventListener("scroll", () => parallax.onScroll());
window.addEventListener("resize", () => parallax.onResize());

API

Parallax

Parallax ⏏

Simple Parallax on DOM elements.

Kind: Exported class

new Parallax(elements, options)

Creates an instance of Parallax.

ParamTypeDescription
elementsArray.<HTMLElement>Elements to be transformed.
optionsOptions

Parallax~Direction : "x" | "y"

Parallax direction (x or y).

Kind: inner typedef of Parallax

Parallax~Options : Object

Kind: inner typedef of Parallax
Properties

NameTypeDefaultDescription
speednumber1Parallax relative speed.
offsetnumber0.5Offset (0 to 1) relative to window height.
heightOffsetnumber0Offset (0 to 1) relative to element height.
directionDirection"y"Parallax direction.
minnumber-InfinityMinimum translation.
maxnumberInfinityMaximum translation.
backgroundbooleanfalseApply parallax to background position instead of transform.

License

MIT. See license file.

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago