I'm redesigning a confluence page that displays various visualizations. I am using the following code:
<div class="carousel">
<img src="image1.jpg">
<img src="image2.jpg">
<img src="image3.jpg">
</div>
CSS (within a style tag):
.carousel {
display: flex;
overflow-x: scroll;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
}
.carousel img {
width: 100%;
scroll-snap-align: start;
}
javascript (within a script tag):
const carousel = document.querySelector(".carousel");
let isDown = false;
let startX;
let scrollLeft;
carousel.addEventListener("mousedown", (e) => {
isDown = true;
startX = e.pageX - carousel.offsetLeft;
scrollLeft = carousel.scrollLeft;
});
carousel.addEventListener("mouseleave", () => {
isDown = false;
});
carousel.addEventListener("mouseup", () => {
isDown = false;
});
carousel.addEventListener("mousemove", (e) => {
if (!isDown) return;
e.preventDefault();
const x = e.pageX - carousel.offsetLeft;
const walk = x - startX;
carousel.scrollLeft = scrollLeft - walk;
});
I have tried using the anchor tag with the href surrounding each image, but it doesn't seem to work within the macro or perhaps the carousel div itself, but I'm totally willing to concede that the CSS or javascript may be the issue here.