AutoHeight breaks on mobile when using dvh units
Author: DonSqualoCreated Jan 22, 2025Updated Sep 18, 2026
LabelsPR Welcome
Check that this is really a bug
- I confirm
Reproduction link
https://codesandbox.io/p/sandbox/swiper-autoheight-forked-xzjhl4
Bug description
When using dynamic units within the slide, AND the slide is initialized WHILE the mobile browser UI is visible, THEN the height calculation is incorrect.
Workaround: ResizeObserver that calls swiper.updateAutoHeight(1) when the window.innerHeight changes
Expected Behavior
The whole content of a Slide should be visible (height should match the content height)
Actual Behavior
On page load the last line of the first slide is not visible because height is to low. When you swipe to the next slide and down (hiding the menu), then swipe back, you CAN see the content.
Swiper version
latest
Platform/Target and Browser Versions
tested on mobile chrome and firefox
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
Source: nolimits4web/swiper