-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (28 loc) · 1.06 KB
/
script.js
File metadata and controls
33 lines (28 loc) · 1.06 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
// const navbar = document.getElementsByTagName("nav")[0];
// const text = document.getElementsByClassName("text")[0];
// window.addEventListener("scroll", function () {
// console.log(window.scrollY);
// if (window.scrollY > 1) {
// navbar.classList.replace("bg-transparent", "nav-color");
// text.classList.replace();
// } else if (window.scrollY <= 0) {
// navbar.classList.replace("nav-color", "bg-transparent");
// }
// });
// SLIDER
var carouselWidth = $(".carousel-inner")[0].scrollWidth;
var cardWidth = $(".carousel-item").width();
var scrollPosition = 0;
$(".carousel-control-next").on("click", function () {
if (scrollPosition < carouselWidth - cardWidth * 4) {
//check if you can go any further
scrollPosition += cardWidth; //update scroll position
$(".carousel-inner").animate({ scrollLeft: scrollPosition }, 600); //scroll left
}
});
$(".carousel-control-prev").on("click", function () {
if (scrollPosition > 0) {
scrollPosition -= cardWidth;
$(".carousel-inner").animate({ scrollLeft: scrollPosition }, 600);
}
});