Sykorax.eu/script/script.js

16 lines
566 B
JavaScript
Raw Permalink Normal View History

2025-04-07 18:26:01 +02:00
function slide(containerId, direction) {
const container = document.getElementById(containerId);
const slides = container.querySelectorAll('.slide');
const currentScroll = container.scrollLeft;
const slideWidth = slides[0].offsetWidth;
const currentIndex = Math.round(currentScroll / slideWidth);
const newIndex = direction === 'next' ?
Math.min(currentIndex + 1, slides.length - 1) :
Math.max(currentIndex - 1, 0);
container.scrollTo({
left: newIndex * slideWidth,
behavior: 'smooth'
});
}