Rounding error in slide size calculation - taking white spaces on the right side of the slide on swiping inside a grid #8111
Unanswered
saleekah1234
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How to solve this issue. I tried adding a function to set a precise width to the slider using containers exact width const setPreciseSlideWidth = (swiper: SwiperCore) => {
// Always set each slide's width to container width + 4px
const swiperEl = swiperRef.current?.querySelector('.swiper') as HTMLElement;
if (swiperEl) {
const preciseContainerWidth = swiperEl.getBoundingClientRect().width;
console.log(preciseContainerWidth,'preciseContainerWidth');
swiper.slides.forEach((slide: HTMLElement) => {
slide.style.width =
${preciseContainerWidth}px;});
swiper.update();
}
}; and called this function in onSlideChange , onSwiper . But doesnt work
Beta Was this translation helpful? Give feedback.
All reactions