I am working with owl carousel and would like to make a vertical image pagination. I already synced the two carousels that need to display the images. There's still no option in owl carousel for doing this and i was wondering if you might help me because my jquery/javascript skills are not too great. Here is the code
jQuery(function($) {
$(document).ready(function() {
var sync1 = $(".owl-vertical-carousel");
var sync2 = $(".owl-vertical-pagination");
var count = $(".owl-vertical-pagination").find('img').length;
var flag = false;
var slides = sync1.owlCarousel({
items: 1,
nav: false,
dots: false,
animateOut: 'fadeOut',
}).on('change.owl.carousel', function(e) {
if (e.namespace && e.property.name === 'position' && !flag) {
flag = true; thumbs.to(e.relatedTarget.relative(e.property.value), 300, true);
flag = false;
}
}).data('owl.carousel');
var thumbs = sync2.owlCarousel({
items: 10,
dots: false,
slideSpeed: 300,
animateOut: 'slideOutUp',
animateIn: 'slideInUp',
nav: true,
navText: [
"<i class='glyphicon glyphicon-menu-left'><</i>",
"<i class='glyphicon glyphicon-menu-right'>></i>",
],
})
.on('click', '.item', function(e) {
e.preventDefault();
sync1.trigger('to.owl.carousel', [$(e.target).parents('.owl-item').index(), 300, true]);
})
.on('change.owl.carousel', function(e) {
}).data('owl.carousel');
});
});
I loop the images with php, but the same can be done with the example owl carousel images.
<div class="fw-col-xs-12 fw-col-sm-4">
<div id="" class="owl-vertical-pagination owl-theme">
<?php $count = count($atts['owl_vertical_carousel']);?>
<?php for($i = 0; $i < $count; $i++) { ?>
<div class="item dragMe">
<img clas="" src="<?php echo $atts['owl_vertical_carousel'][$i]['url']; ?>">
</div>
<?php } ?>
</div>
</div>
<div class="fw-col-xs-12 fw-col-sm-8">
<div id="" class="owl-vertical-carousel owl-theme">
<?php $count = count($atts['owl_vertical_carousel']);?>
<?php for($i = 0; $i < $count; $i++) { ?>
<div class="item">
<img src="<?php echo $atts['owl_vertical_carousel'][$i]['url']; ?>">
</div>
<?php } ?>
</div>
</div>
And my css
.owl-vertical-carousel .item img {
width: 100%;
height: auto;
}
.owl-vertical-pagination .owl-stage-outer .owl-stage {
margin: 0 auto;
}
.owl-vertical-pagination .owl-item {
width: 100% !important;
margin: 10px;
}
.owl-vertical-pagination .item img {
cursor: pointer;
}
.owl-theme .owl-nav .owl-prev {
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.owl-theme .owl-nav .owl-next {
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
The items option works horizontally, as well as the navigation arrows, so even if the images are displayed vertically it will still work for left and right, as you might notice if you drag the images. I need to show only 4 items vertically at a time, and hide the rest. The arrows for next and previous should also work.
Thanks