Variable Size Thumbnails #277
-
Thank you for making this library. I was recommended to use Keen-Slider, which looks good, but after trying it out for a bit and reading online I heard about this one, which I was more impressed with. I am wondering is there are any examples out there of a thumbnail carousel with variable width images, or if in the y-axis (which is what I am trying to do), variable height images. I can get my images to look right, with variable heights and 100% width of the carousel container, but then the scroll breaks. It will move up and down, but always snap back to the original position and selecting an item doesn't move it. I can get the scroll to work, though, if the height is set statically. This is from the thumbnails example. I don't know what's happening here at all.
Whenever I've gotten the sizes to look right, I've always had to remove Thanks for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Hi @calvinsomething, Embla reads the The main problem being that if you don't specify any height, your thumbnails won't have any height until the images have loaded. And if you initialize your thumbnail carousel before the thumbnails have any height, calculating the scroll positions from the slide heights will fail. If your image endpoint provides the image sizes from the server, you can create placeholders for your thumbnails when server side rendering them. If not, you probably have to add some logic that initializes the thumb carousel only when all thumbnail images have loaded. If this approach suits you better, you can conditionally render your carousel as described here. About the strange CSS 😅, that's a hack to mimic Best, |
Beta Was this translation helpful? Give feedback.
Hi @calvinsomething,
Embla reads the
getBoundingClientRect().height
property on your slides whenaxis: 'y'
in order to calculate the slide positions. The scroll probably breaks becausegetBoundingClientRect().height
returns0
when you don't specify any height on your vertical thumbnails:The main problem being that if you don't specify any height, your thumbnails won't have any height until the images have loaded. And if you initialize your thumbnail carousel before the thumbnails have any height, calculating the scroll positions from the slide heights will fail.
If your image endpoint provides the image sizes from the server, you can create placeholders for your thumbnails when server s…