-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Vertical Swiper + autoHeight #4599
Comments
It seems that this problem still exists. I recon more people want to use the |
+1, same problem |
Also having this issue. It takes up infinite space and causes the entire thing to be a real pain to style. |
+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). |
+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 |
+1 same here. Any update about this? |
+1 facing same issue. Swiper vertical height does not work when slides are of different heights (with or without virtualization enabled). Setting height to |
Any update about this? |
+1 Any update on this would be great. |
+1 would appreciate this feature |
This approach helped me. https://codepen.io/pylvin/pen/WNJWexR But it will not work if you use |
+1, same problem |
Same issue here. It would be great if |
I would also love a fix for this to be implemented, please. |
Same problem |
same problem |
1 similar comment
same problem |
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. |
+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.
|
same issue, any updates? |
same here. switched to horizontal because i couldn't come up with a good solution. |
+1 |
Just use this .your-slider .swiper-slide{ |
Thank you anyway, although it didn't work for me.
|
I have the same problem, a fix would be awesome. |
@ALL - just update to last version :) |
@marinvalentin: I am using the latest version of @mrgvd: In my particular case your fix (setting |
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 |
because of #child_element <div class="swiper-slide" >
<div id="child_element">Slide 1< /div>
</div> |
Combination of both fixed the issue for me autoHeight: true, .swiper-slide { |
Some people here is writing that the solution of ".swiper-slide { height: auto !important }" is working ... but I think it's not. I took the original demo of autoHeight of Swiper and add that CSS ... as you can see when you scroll , there is an important glitch that you see the "height" of the slide but with the content of other slide: https://codepen.io/cptacco/pen/XWorJYO Any ideas, please ? |
probably not a good idea to give the height statically https://codepen.io/mostafa-nematpour/pen/yLGBNOw ... .swiper { .swiper-slide { |
THANK YOU VERY MUCH ... but I'm looking for a "auto height", so if a slide has less height, the container should be auto to that active slide height. |
Ok friends, for those who do not work with the proposed CSS solution, I propose another new solution that has worked for me. The problem is that the snapGrid is miscalculated, and I think I could fix it in a very dirty way, but as the code is not mine, and I didn't want to analyze the 9000 lines of code of the deminified code, I preferred to opt for a solution that may be a little "dirty" but works like a charm. It is to use the events so, when Swiper finishes making its calculations and move the translate3D of the wrapper to the position that he believes correct (which is what fails, as the author of this thread said), move it manually calculating the height that should be moved, which is the sum of the heights of the previous divs with the sum of the space between them. Here is the code:
You can find the CodePen updated (from my original post 1 hour ago) here: |
Setting a max-height on the swiper-wrapper worked well for me. You may need to play around with it for your use case depending on your slides per view. Didn't need to use the swiper autoHeight or max-height auto on the slides. Haven't tested with looping or anything, just the standard vertical swiper. |
I had the same problem, the solution I found was to rewrite the functions that calculate the height of the wrapper and the one that updates the slides. It's not perfect and it could be much better with a bit of work, but it works in my case. CSS :
HTML :
JS :
|
This helped me: |
this helped me, thanks |
This "HACK" works perfectly even loop is set to true!
|
i explain more. react
css
@buidanmo thanks!!! 😊 |
I just change height parameter (100% to 100vh) .swiper-slide{ and works fine! |
|
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 withdirection: '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.The text was updated successfully, but these errors were encountered: