More actions
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
const carousel = document.querySelector(".card-carousel"); | const carousel = document.querySelector(".card-carousel"); | ||
| Line 39: | Line 38: | ||
}); | }); | ||
}); | }); | ||
Revision as of 14:45, 30 May 2025
/* Any JavaScript here will be loaded for all users on every page load. */
document.addEventListener("DOMContentLoaded", function () {
const carousel = document.querySelector(".card-carousel");
let isDragging = false;
let startX;
let scrollLeft;
if (!carousel) return;
carousel.addEventListener("pointerdown", (e) => {
isDragging = true;
carousel.classList.add("dragging");
startX = e.pageX;
scrollLeft = carousel.scrollLeft;
carousel.setPointerCapture(e.pointerId);
e.preventDefault();
});
carousel.addEventListener("pointermove", (e) => {
if (!isDragging) return;
const x = e.pageX;
const walk = (x - startX) * 1.5; // Adjust scroll speed if needed
carousel.scrollLeft = scrollLeft - walk;
e.preventDefault();
});
carousel.addEventListener("pointerup", () => {
isDragging = false;
carousel.classList.remove("dragging");
});
carousel.addEventListener("pointerleave", () => {
isDragging = false;
carousel.classList.remove("dragging");
});
});