swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Vertical Swiper + autoHeight

Open niklasp opened this issue 3 years ago • 42 comments

Is your feature request related to a problem? Please describe. For many use cases, vertical sliders are the best solution. It would be a great addition to swiper if autoHeight would work for swipers with direction: 'vertical' as well.

Describe the solution you'd like I would love to see a swiper that works just like the autoHeight mode in horizontal, it should measure the height of the current slide (or if more than one, the heighest) and adjust the wrapper height to it.

Describe alternatives you've considered Fixed height sliders work well with vertical mode but that is not always the best solution.

Additional context @nolimits4web mentioned that it is only for 'horizontal', is there a reason for that?

I tried with custom css js and events to calculate the height correctly in the correct place but could not find the right event with the right code needed. The closest I could get is this codesandbox:

https://codesandbox.io/s/swiper-vertical-forked-2gklb?file=/index.html

The wrapper gets the correct height but the slide offset is wrong. A hint for a workaround would also be helpful. I nonetheless consider autoHeight + direction: vertical a very good match.

niklasp avatar May 22 '21 21:05 niklasp

It seems that this problem still exists. I recon more people want to use the autoHeight + direction: vertical combination. Have you found a workaround for this @niklasp? I'm still looking but when I find a solution I will let you know if you still need it ;)

benjamin3105 avatar Oct 15 '21 08:10 benjamin3105

+1, same problem

hasenov avatar Nov 26 '21 11:11 hasenov

Also having this issue. It takes up infinite space and causes the entire thing to be a real pain to style.

tunztunztunz avatar Dec 01 '21 23:12 tunztunztunz

+1, as it mentioned the height get messed up, hope there is a way to solve this issue on vertical direction (At the moment I have disabled the option on vertical direction to avoid this issue).

mohammedrezq avatar Jan 05 '22 12:01 mohammedrezq

+1

Im trying to create a vertical thumbnail navigation for a ecommerce product gallery and this issue came up.

my temporaly solution was manually set swiper-slide class css height to auto. but this gets messed up when loop = true

andreomcn avatar May 06 '22 19:05 andreomcn

+1 same here.

Any update about this?

antoniofalcone89 avatar Jun 21 '22 20:06 antoniofalcone89

+1 facing same issue.

Swiper vertical height does not work when slides are of different heights (with or without virtualization enabled). Setting height to auto breaks the logic of setting top position since it still gets set on the basis of <total height> / number of vertical slide. Is there any workaround for this.

prate3k avatar Aug 04 '22 15:08 prate3k

Any update about this?

yuuk avatar Aug 05 '22 14:08 yuuk

+1

Any update on this would be great.

marcruecker avatar Sep 06 '22 14:09 marcruecker

+1 would appreciate this feature

kappi94 avatar Sep 14 '22 11:09 kappi94

This approach helped me.

https://codepen.io/pylvin/pen/WNJWexR

But it will not work if you use loop:true

kiyoshi-satoo avatar Oct 16 '22 14:10 kiyoshi-satoo

+1, same problem

mostafa-nematpour avatar Oct 31 '22 10:10 mostafa-nematpour

Same issue here. It would be great if autoHeight worked correctly with vertical

mapsmarketing avatar Nov 14 '22 05:11 mapsmarketing

I would also love a fix for this to be implemented, please.

enzocomics avatar Dec 17 '22 08:12 enzocomics

Same problem

marinvalentin avatar Dec 20 '22 13:12 marinvalentin

same problem

barzles avatar Jan 18 '23 16:01 barzles

same problem

cuonghuynh avatar Feb 10 '23 02:02 cuonghuynh

I've swapped it to use Slick Slider instead as the vertical nav works much better on it. It might not be as feature rich as swiper but at least it gets it done.

mapsmarketing avatar Feb 10 '23 03:02 mapsmarketing

+1 same here :/ need it in combination with direction: "vertical" and loop: true. Any suggestions?

sarah-baldin avatar Feb 14 '23 20:02 sarah-baldin

+1 same here :/ need it in combination with direction: "vertical" and loop: true. Any suggestions?

I have ecommerce product page with the main (selected) image alongside with the product gallery on the left side. I've managed to accomplish what I needed by doing the following steps:

  • a flex container with position: relative wrapping both sliders (vertical gallery slider and selected image slider).
  • flex: 1 on gallery slider (you can change this to fit the horizontal width you need)
  • flex: 5 on main image slider (you can change this to fit the horizontal width you need)
  • position: absolute on the .swiper-wrapper child from the gallery slider (prevents from growing endlessly)
  • slide images (img) from both sliders with width: 100%; height: 100%; object-fit: contain;

shoxton avatar Feb 14 '23 21:02 shoxton

same issue, any updates?

realdaly avatar Mar 01 '23 05:03 realdaly

same here. switched to horizontal because i couldn't come up with a good solution.

mattbarnicle avatar Mar 04 '23 11:03 mattbarnicle

+1 Any update on this would be great.

skyFi avatar Mar 24 '23 06:03 skyFi

Just use this

.your-slider .swiper-slide{ height: auto!important; }

mrgvd avatar Mar 26 '23 16:03 mrgvd

Thank you anyway, although it didn't work for me.

Just use this

.your-slider .swiper-slide{ height: auto!important; }

skyFi avatar Mar 27 '23 02:03 skyFi

I have the same problem, a fix would be awesome.

JoshDHBW avatar Mar 30 '23 18:03 JoshDHBW

@all - just update to last version :)

marinvalentin avatar Mar 30 '23 18:03 marinvalentin

@marinvalentin: I am using the latest version of swiper (9.2.2) and still have this issue.

@mrgvd: In my particular case your fix (setting height: auto !important on the swiper slide element) indeed helped, thanks!

strarsis avatar Apr 17 '23 02:04 strarsis

Same here.

It looks like it's taking the height of the parent element to define the item height, if you set a fixed height for the swiper-wrapper then the slider item will work. It would be great to have an option like heightTarget or something like that which by default would be the parent element, but you could pass the children parameter, just guessing...

Giovancruz avatar Apr 20 '23 00:04 Giovancruz

because of #child_element < div class="swiper-slide" > < div id="child_element">Slide 1< /div> < /div>

hheinsoee avatar Jul 04 '23 04:07 hheinsoee