Open thdoan opened 3 years ago
Hey dude. Did you ever figure out a workaround?
@televators we ended up using an aspect ratio mixin to keep the thumbnails at the same aspect ratio as the main image:
/**
* [Adds styles to allow an element's height scale proportionatelly]
* @param {[Number]} $width
* @param {[Number]} $height
*/
@mixin aspect-ratio($w, $h, $usePseudo: false, $adjust: 0px) {
$calcH: aspect-ratio-height($w, $h);
$finalH: if( $adjust != 0px, calc( #{$calcH} + #{$adjust} ), $calcH );
@if ($usePseudo) {
position: relative;
&:before {
display: block;
content: '';
padding-bottom: $finalH;
width: 100%;
}
}
@else {
height: 0;
padding-bottom: $finalH;
}
}
/**
* [Calculates the percentage aspect ratio (what % height is compared to the width)]
* @param {[Number]} $width
* @param {[Number]} $height
* @return {[Number(%)]}
*/
@function aspect-ratio-height($width, $height){
@return percentage($height / $width);
}
Sample usage assuming the image has a 1:1.25 aspect ratio:
<li class="slick-slide">
<button class="slick-slide__button"><img></button>
</li>
.slick-slide__button {
@include aspect-ratio(1, 1.25, true);
}
Notes:
<img>
was wrapped in <button>
to comply with ADAaspect-ratio()
in .slick-slide
instead, but didn't want any potential conflicts with Slick.
I've observed an intermittent issue where sometimes the vertical slider is rendered with an incorrect container height. This appears to be caused by the
<ul>
havingdisplay: flex
.====================================================================
What is the expected behaviour?
The vertical thumbnails slider is created in an overlay, that usually looks like this:
Correct container height:
====================================================================
What is observed behaviour?
However, upon closing this overlay and reopening it, the thumbnails slider is reduced to 24px height:
Incorrect container height:
====================================================================
More Details