-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.js
46 lines (38 loc) · 1.71 KB
/
services.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
const initSlider = () => {
const imageList = document.querySelector(".slider-wrapper .image-list");
const slideButtons = document.querySelectorAll(".slider-wrapper .slide-button");
// Slide images according to the slide button clicks
slideButtons.forEach(button => {
button.addEventListener("click", () => {
const direction = button.id === "prev-slide" ? -1 : 1;
const scrollAmount = imageList.clientWidth * direction;
imageList.scrollBy({ left: scrollAmount, behavior: "smooth" });
});
});
// Call these two functions when image list scrolls
imageList.addEventListener("scroll", () => {
updateScrollThumbPosition();
// handleSlideButtons();
});
}
window.addEventListener("resize", initSlider);
window.addEventListener("load", initSlider);
// video
// const initSlidervideo = () => {
// const imageList = document.querySelector(".slider-wrapper .video-list");
// const slideButtons = document.querySelectorAll(".slider-wrapper .slide-button-video");
// // Slide images according to the slide button clicks
// slideButtons.forEach(button => {
// button.addEventListener("click", () => {
// const direction = button.id === "prev-slide-video" ? -1 : 1;
// const scrollAmount = imageList.clientWidth * direction;
// imageList.scrollBy({ left: scrollAmount, behavior: "smooth" });
// });
// });
// // Call these two functions when image list scrolls
// imageList.addEventListener("scroll", () => {
// updateScrollThumbPosition();
// });
// }
// window.addEventListener("resize", initSlidervideo);
// window.addEventListener("load", initSlidervideo);