if suggest-slider length var owl5 suggest-slider owl5 owlCarousel loop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
if($('#suggest-slider').length > 0){
var owl5 = $("#suggest-slider");
owl5.owlCarousel({
loop: true,
items: 1,
onChanged: changeActiveBlock
});
function changeActiveBlock(event) {
var page = event.page.index;
if (page != '-1') {
$('.suggest-item').removeClass('active');
}
$('.suggest-item[data-num="'+page+'"]').addClass('active');
}
$(".suggest-item").on("click", function() {
owl5.trigger('to.owl.carousel', $(this).data('num'));
$('html, body').animate({
scrollTop: $("#suggest-slider").offset().top
}, 500);
return false;
});
}