-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
106 lines (87 loc) · 2.14 KB
/
index.js
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//headeri responsive
document.addEventListener("DOMContentLoaded", function() {
hamburger = document.querySelector(".hamburger");
let ballina = document.querySelector(".ballina");
let initialMarginTop = ballina.style.marginTop;
if (ballina) {
hamburger.onclick = function(){
navBar = document.querySelector(".nav-bar");
navBar.classList.toggle("active");
if (navBar.classList.contains("active")) {
ballina.style.marginTop = "350px";
} else {
ballina.style.marginTop = initialMarginTop;
}
}
}
});
//slider
const slides = document.querySelectorAll(".slide");
const nextBtn = document.querySelector(".nextBtn");
const prevBtn = document.querySelector(".prevBtn");
slides.forEach(function (slide, index) {
slide.style.left = `${index * 100}%`;
});
let counter = 0;
nextBtn.addEventListener("click", function () {
counter++;
carousel();
});
prevBtn.addEventListener("click", function () {
counter--;
carousel();
});
function carousel() {
// working with slides
// if (counter === slides.length) {
// counter = 0;
// }
// if (counter < 0) {
// counter = slides.length - 1;
// }
// working with buttons
if (counter < slides.length - 1) {
nextBtn.style.display = "block";
} else {
nextBtn.style.display = "none";
}
if (counter > 0) {
prevBtn.style.display = "block";
} else {
prevBtn.style.display = "none";
}
slides.forEach(function (slide) {
slide.style.transform = `translateX(-${counter * 100}%)`;
});
}
prevBtn.style.display = "none";
// slideri i lajmeve
var swiper = new Swiper(".card_slider", {
spaceBetween: 40,
loop: true,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
breakpoints: {
320: {
slidesPerView: 1,
},
480: {
slidesPerView: 2,
},
768: {
slidesPerView: 3,
},
960: {
slidesPerView: 4,
},
1024: {
slidesPerView: 5,
},
},
});