Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lemehovskiy/parallax-background

Vanilla JS parallax background plugin based on GSAP
https://github.com/lemehovskiy/parallax-background

animation greensock gsap parallax typescript vanilla-js

Last synced: 2 months ago
JSON representation

Vanilla JS parallax background plugin based on GSAP

Awesome Lists containing this project

README

        

parallax-background
-------

Create captivating parallax backgrounds effortlessly with the ParallaxBackground plugin. This lightweight Vanilla JavaScript plugin, powered by GSAP animation, supports Scroll, Mouse Move, and Gyroscope events. Choose from Rotate or Shifting animations, and easily configure zoom and animation duration for a personalized touch.

Features:

* Vanilla JavaScript and GSAP powered
* Scroll, Mouse Move, Gyroscope events
* Rotate or Shifting animations
* Customizable zoom and animation duration

### Demo

[Basic demo](https://codesandbox.io/p/devbox/parallax-background-basic-demo-r3qmzy)

[Events types and animation types demo](https://codesandbox.io/p/devbox/parallax-background-demo-events-animation-types-48fk64)

### Package Managers

```sh
# NPM
npm install parallax_background
```

### Installation

#### Include js

```html

```

#### Set HTML

```html





```

#### Call the plugin

```html

//Initialize with Vanilla JavaScript
new ParallaxBackground(document.querySelector(".parallax-background"));
//Initialize with jQuery
$(document).ready(function() {
$('.parallax-background').parallaxBackground();
});

```

#### In result

```html


My website





//optional for jQuery initialize


//Initialize with Vanilla JavaScript
new ParallaxBackground(document.querySelector(".parallax-background"));
//Initialize with jQuery
$(document).ready(function() {
$('.parallax-background').parallaxBackground();
});

```

### Data Attribute Settings

In parallax-background you can add settings using the data-parallax-background attribute. You still need to call
new ParallaxBackground(selector)
to initialize parallax-background on the element.

Example:

```html





```

### Settings

Option | Type | Default
--- | --- | ---
events | [SCROLL, MOUSE, GYRO] | [SCROLL]
animationType | SHIFT \| ROTATE | SHIFT
zoom | int | 20
rotatePerspective | int | 1400
animateDuration | int | 1

### Browser support

* Chrome
* Firefox

### Dependencies

* GSAP animation library (Version 3.10.4)

## Contributing

If you'd like to get involved, please consider opening an issue or submitting a pull request. Your input is highly valued, and I'm enthusiastic about collaborating to enhance this tool.

## License

parallax-background is released under the MIT License. See the [LICENSE](LICENSE) file for comprehensive details regarding the terms and conditions of use.