_carousels.js
2.02 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import Swiper, {
Navigation,
Pagination,
A11y,
Keyboard
} from 'swiper';
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
import 'swiper/css/keyboard';
import 'swiper/css/a11y';
import LazyLoad from "vanilla-lazyload";
jQuery(document).ready(function($) {
jQuery('.carousel-items').each(function() {
//var offset = ((window.innerWidth - $('#content').width()) / 2) - 28;
//var offsetAfter = ((window.innerWidth - $('#content').width()) / 2) - 28;
var offsetAfter = 0;
var PerView = 1
var offset =0;
var space = 20;
var SlidesPerGroup= 1;
var _id = jQuery(this).parent().attr('id');
if ($(window).width() < 600) {
offset = 0;
PerView = 1;
SlidesPerGroup = 1;
space = 0;
offsetAfter = 0;
}
var swiper_params = {
modules: [Navigation, Pagination, A11y, Keyboard],
slidesPerView: PerView,
slidesOffsetAfter: offsetAfter,
slidesOffsetBefore: offset,
spaceBetween: space,
slidesPerGroup: SlidesPerGroup ,
centeredSlides: true,
loop: false,
lazy: true,
pagination: {
el: ".swiper-pagination",
type: 'bullets',
clickable: "true",
},
navigation: {
nextEl: '.swiper-button-next[data-id="' + _id + '"]',
prevEl: '.swiper-button-prev[data-id="' + _id + '"]',
},
a11y: {
prevSlideMessage: 'Previous slide',
nextSlideMessage: 'Next slide',
},
keyboard: {
enabled: true,
onlyInViewport: false,
},
};
var mySwiper = new Swiper(this, swiper_params);
});
$('.carousel ').css('margin-left',"-"+$('#content').css('margin-left'));
$(window).on('resize', function(){
$('.carousel ').css('margin-left',"-"+$('#content').css('margin-left'));
});
});