Skip to content

Layout shift when rendering react-glider container on the server #130

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

Closed
kevinfarrugia opened this issue Oct 6, 2022 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@kevinfarrugia
Copy link
Owner

At the moment, before the Glider is initialised, the items in the glider-contain do not appear correct and are shifted as the Glider loads.

demo

The user can choose to:

  • Incur a layout shift
  • Not show the content until the Glider has initialized

This is related to an issue on Glider.js. See NickPiscitelli/Glider.js#235

@kevinfarrugia kevinfarrugia added the bug Something isn't working label Oct 6, 2022
@agboolaidris
Copy link

I am also facing the same issue.
@kevinfarrugia do you forget any solution to this bug?

@kevinfarrugia
Copy link
Owner Author

@agboolaidris I currently recommend solving this using CSS rather than changing the underlying behavior in Glider.js. There isn't a single solution that applies for all cases, but in most cases you are able to fix this using CSS.

For example, I have updated a demo built using Next: https://next-react-glider.vercel.app/ to solve this issue using CSS. In this case I added the following CSS:

.track:not(:global(.glider-track)) {    
  display: flex;
  flex-direction: row;
  overflow-x: hidden;
}

.slide:not(:global(.glider-slide)) {
  flex: 0 0 calc(100% - 2rem);
}

I have also seen a similar technique in use on production websites, for example on https://mfa.com.mt/ where the height attribute of the banner is fixed and the other banners are hidden using overflow: hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants