Skip to main content

Creating An Instance

Use the ParallaxController.init() method to instantiate a new controller tied to a view element. By default one will be created for vertical scrolling tied to the body scroll element.

const instance = ParallaxController.init();

With Options

You can pass options to the init() method options that will change the default axis and provide a different scrolling element.

const scrollContainer = document.getElementById('your-scroll-container');
const instance = ParallaxController.init({
scrollAxis: 'horizontal',
scrollContainer,
});

Init Options

The following option can be passed to ParallaxController.init(...).

OptionDefaultDescription
scrollAxis'vertical'Direction of scroll for the element. One of 'vertical' or 'horizontal'
disabledfalseInitial disabled state of the Parallax Controller
scrollContainerwindowHTMLElement that will contain scroll elements.