Answer the question
In order to leave comments, you need to log in
How to adjust the next/prev buttons to the modified Owl Carousel 2 script?
The usual Owl Carousel 2, with not much changes, added this piece to determine the location of the active element and automatically start from it when the page loads
var poWidth = $(".owl-item").width(); // Узнаем ширину одного элемента
var poWidthBlock = $(".owl-wrapper-outer").width(); // Узнаем ширину внешнего блока
var poAll = $(".owl-item").length; // Всего элементов в каруселе
var poPrev = $("#inside").prevAll().length; // Количество элементов перед выбранным
var poResultMax = poWidth * poAll - poWidthBlock + 1; // Максимальное расстояние
var poResult = poWidth * poPrev; // Расстояние к активному элементу
if (poResult <= poResultMax) {
var poRes = poResult;
} else {
var poRes = poResultMax;
}
base.$elem.find(".owl-wrapper").css("display", "block");
base.$elem.find(".owl-wrapper").css("transform", "translate3d(-" + poRes + "px, 0px, 0px)"); // Результат
Answer the question
In order to leave comments, you need to log in
Jupiter Max , Chet does not work this function. But thanks for suggesting the direction, and the answer will be this code
$(document).ready(function() {
var owl = $("#owl-serial").owlCarousel({
items : 4,
itemsDesktop : [1199,3],
itemsDesktopSmall : [979,3]
});
var poPrev = $("#inside").prevAll().length; // Номер нужного слайда
// Now move the carousel to the third item.
owl = $("#owl-serial").data('owlCarousel');
owl.jumpTo(poPrev);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question