Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when used on the same page as JS accordion #245

Open
hbgreg opened this issue Nov 7, 2022 · 1 comment
Open

Problem when used on the same page as JS accordion #245

hbgreg opened this issue Nov 7, 2022 · 1 comment

Comments

@hbgreg
Copy link

hbgreg commented Nov 7, 2022

Hi,

I have an accordion that opens and closes divs on click. When they are all open, the rellax content in a lower section gets pushed out of its wrapper in overlaps other content.

@ncoetzer
Copy link

ncoetzer commented Oct 10, 2023

@hbgreg Perhaps you found a solution already, but I had the same issue and solved it by using the ResizeObserver API to listen to any resizing on the body element and call the refresh() method to keep things in place. Something like this:

// Initialize Rellax
const rellax = new Rellax('.js-rellax', { center: true });
rellax.refresh();

// Let's listen for any resize events on the body element,
// such as expanding accordions and refresh the rellax to keep
// the centering in place and avoid any overlapping with content
const bodyObserver = new ResizeObserver((entries) => {
    entries.forEach(() => {
	rellax.refresh();
    });
});

Hope this helps 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants