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

SwiperSlide can not calculate height when slide re-enters document flow #7763

Open
5 of 6 tasks
Mardoxx opened this issue Oct 10, 2024 · 4 comments
Open
5 of 6 tasks
Labels

Comments

@Mardoxx
Copy link

Mardoxx commented Oct 10, 2024

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/devbox/swiper-react-pagination-forked-rphtm9?workspaceId=35d6dd92-3dc6-4c2e-8d07-68fda293fe48

Bug description

I am trying to full screen a swiper slide by pulling it out of the document flow (position fixed).
When I re-set the slide back into the document the size it calculates is incorrect.

I have tried using swiper.update() and this does not help

Expected Behavior

Document remains "full window height".

No response

Actual Behavior

Document ends up being "full window height + footer height"

No response

Swiper version

11.1.14

Platform/Target and Browser Versions

Edge/Chrome

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@Mardoxx Mardoxx added the React label Oct 10, 2024
@Mardoxx
Copy link
Author

Mardoxx commented Oct 10, 2024

I've "fixed" it (App_fixed.jsx) by doing

swiperRef.current.slides[ swiperRef.current.activeIndex ].style.height = "0";

on the close, which I guess causes a re-render, n.b. this does not work with userSwiper. Setting it to 100% or 100vh will break it. Setting it to 0 makes it flash (I suppose as it re-renders?). A workaround is to wrap the swiper in another full height div and use that as the source height.

@Mardoxx
Copy link
Author

Mardoxx commented Oct 10, 2024

Is there a recommended pattern for full screening slides?

@Mardoxx
Copy link
Author

Mardoxx commented Oct 11, 2024

It breaks if there are multiple slides like this also

@Mardoxx
Copy link
Author

Mardoxx commented Oct 11, 2024

It seems that if the swiper is inside an unbounded parent (e.g. flex-grow) it doesn't know how to compute the height so extends to infinity

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

No branches or pull requests

1 participant