Created
March 19, 2018 11:30
-
-
Save Tusko/8c08ff1c3328cc333b65a550f2b004c6 to your computer and use it in GitHub Desktop.
Horizontal swiper gallery like masonry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $gallery_instance = 1; | |
if($tpl === 'horizontal_gallery' && $flex['gallery']) { $g = 1; ?> | |
<div class="horizontal-gallery row"> | |
<div class="swiper-container"> | |
<div class="swiper-wrapper"> | |
<?php foreach ($flex['gallery'] as $img) { ?> | |
<div class="swiper-slide <?php echo ($g % 3) == 0?'swiper-slide-fh':''; ?>"> | |
<a class="cover" href="<?php echo $img['url']; ?>" data-fancybox="gallery-<?php echo $gallery_instance++; ?>" style="<?php echo image_src($img['ID'], 'large', true); ?>"></a> | |
<div class="e-space"></div> | |
<?php echo ($g % 3) == 0?'</div><div class="swiper-slide swiper-slide-empty">':''; ?> | |
</div> | |
<?php $g++; } ?> | |
</div> | |
<div class="swiper-button-prev"></div> | |
<div class="swiper-button-next"></div> | |
</div> | |
</div> | |
<?php } | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.horizontal-gallery').each(function(i){ | |
var h = $('.swiper-container', this)[0]; | |
setTimeout(function(){ | |
window.WPASwiper['hg-'+i] = new Swiper( h, { | |
navigation: { | |
nextEl : $('.swiper-button-next', h)[0], | |
prevEl : $('.swiper-button-prev', h)[0] | |
}, | |
roundLengths : true, | |
observer : true, | |
observeParents : true, | |
speed : 500, | |
slidesPerView : 2, | |
slidesPerColumn : 2, | |
spaceBetween : 6 | |
}); | |
}, 1e3*i); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.horizontal-gallery { | |
.swiper-slide { | |
.e-space { | |
&:before { | |
padding-bottom: 49.315%; | |
display: block; | |
content: ''; | |
} | |
} | |
> a { | |
@include position(absolute); | |
} | |
&.swiper-slide-fh { | |
> a { | |
bottom: -102% | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment