Public Methods
The following methods are available on a controller instance
createElement()â
Creates and returns a new parallax element with provided config including props to be managed by the controller.
const options = {
el: document.querySelector('.your-element'),
props: { translateY: [-100, 100] },
};
const element = parallaxController.createElement(options);
getElements()â
Returns all the parallax elements in the controller.
const elements = parallaxController.getElements();
updateElementPropsById()â
Updates an existing parallax element with new props.
const newProps = { translateY: [-200, 200] };
parallaxController.updateElementPropsById(element.id, newProps);
removeElementById()â
Removes an element from the controller by ID (does not call destroy() on the element).
parallaxController.removeElementById(element.id);
resetElementStyles()â
Resets parallax styles on a managed element (the Element instance returned from createElement(), not a raw DOM node).
parallaxController.resetElementStyles(element);
updateScrollContainer()â
Updates the scroll container of the parallax controller. Rebuilds the internal view, reattaches window listeners, and re-creates the ResizeObserver on the new container (when the controller is not disabled).
const el = document.getElementById('your-scroll-container');
parallaxController.updateScrollContainer(el);
disable()â
Disables the controller: removes window listeners and the resize observer, and disables all managed elements.
parallaxController.disable();
disableParallaxController() is an alias for disable().
enable()â
Re-enables the controller: restores listeners, the resize observer, view size, and all managed elements.
parallaxController.enable();
enableParallaxController() is an alias for enable().
disableParallaxController()â
Alias for disable().
parallaxController.disableParallaxController();
enableParallaxController()â
Alias for enable().
parallaxController.enableParallaxController();
update()â
Updates all cached attributes on parallax elements.
parallaxController.update();
destroy()â
Removes all listeners and resets all styles on managed elements.
parallaxController.destroy();