Skip to content

Parallax

This component is made on top of the Cover component.

Example

html
<div class="cover parallax" style="background-image: url('/background.jpg');"></div>

JavaScript

Import

js
import { SparkleParallax } from '@sparkleui/sparkle';

Initialize

js
const sparkleParallax = new SparkleParallax(document.querySelector('.parallax'));
sparkleParallax.mount();

Options

js
const sparkleParallax = new SparkleParallax(document.querySelector('.parallax'));
sparkleParallax.mount({
    scrollSpeed: 2,
});
html
<div class="cover parallax" style="background-image: url('/background.jpg');" data-parallax='{"scrollSpeed": 2}'></div>

Released under the MIT License.