So, I'm using SwiperJs with autoheight. I expected that on slide change the container adapts its height depending on the content (simple images in my case). And it does update on slide change.
The problem is that on first load the slide seems to miscalculate the height and makes it a square, ignoring the content height.
This are my dependencies:
"dependencies": {
"next": "12.1.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"swiper": "^8.2.4"
},
This is the ponent:
return (
<article className='card mb-8 block'>
<div className='w-full'>
<Swiper autoHeight loop spaceBetween={0} slidesPerView={1}>
{images.map((image, i) => {
return (
<SwiperSlide key={i}>
<div className='custom-img-container'>
<Image className='custom-img' layout='fill' src={image} objectFit='cover' />
</div>
</SwiperSlide>
)
})}
</Swiper>
</div>
</article>
)
So, I'm using SwiperJs with autoheight. I expected that on slide change the container adapts its height depending on the content (simple images in my case). And it does update on slide change.
The problem is that on first load the slide seems to miscalculate the height and makes it a square, ignoring the content height.
This are my dependencies:
"dependencies": {
"next": "12.1.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"swiper": "^8.2.4"
},
This is the ponent:
return (
<article className='card mb-8 block'>
<div className='w-full'>
<Swiper autoHeight loop spaceBetween={0} slidesPerView={1}>
{images.map((image, i) => {
return (
<SwiperSlide key={i}>
<div className='custom-img-container'>
<Image className='custom-img' layout='fill' src={image} objectFit='cover' />
</div>
</SwiperSlide>
)
})}
</Swiper>
</div>
</article>
)
Share
Improve this question
edited May 31, 2024 at 12:41
Sébastien Gicquel
4,3867 gold badges57 silver badges87 bronze badges
asked Jun 21, 2022 at 17:59
Nuno LemosNuno Lemos
111 silver badge5 bronze badges
1 Answer
Reset to default 6I added these two properties and it seems to work fine:
observer: true,
observeParents: true,
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744219681a4563720.html
评论列表(0条)