Skip to main content
Version: 2.0 Beta

Creating An Instance

Use the ParallaxController.init() method to instantiate a new controller tied to a view. By default, one is created for vertical scrolling against the window (document viewport). You must call init() on the client; it throws if window is undefined (for example during SSR).

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 options 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.