diff --git a/multigranja/apps/entities/static/rotation/js/rotation_list.js b/multigranja/apps/entities/static/rotation/js/rotation_list.js new file mode 100644 index 0000000..a4247b2 --- /dev/null +++ b/multigranja/apps/entities/static/rotation/js/rotation_list.js @@ -0,0 +1,39 @@ +document.addEventListener("DOMContentLoaded", () => { + const container = document.querySelector(".open-rotations-container"); + + if (!container) return; + + let targetScroll = container.scrollLeft; + let currentScroll = container.scrollLeft; + let isAnimating = false; + + container.addEventListener("wheel", (event) => { + event.preventDefault(); + + const maxScroll = + container.scrollWidth - container.clientWidth; + + targetScroll += event.deltaY; + + // Prevent ghost scrolling + targetScroll = Math.max(0, Math.min(targetScroll, maxScroll)); + + if (!isAnimating) { + isAnimating = true; + animateScroll(); + } + }); + + function animateScroll() { + currentScroll += (targetScroll - currentScroll) * 0.15; + + container.scrollLeft = currentScroll; + + if (Math.abs(targetScroll - currentScroll) > 0.5) { + requestAnimationFrame(animateScroll); + } else { + currentScroll = targetScroll; + isAnimating = false; + } + } +}); \ No newline at end of file