Download tasks/eventbrite/solution/site/implementation/clone/static/js/carousel.js from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/eventbrite/solution/site/implementation/clone/static/js/carousel.js
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/eventbrite/solution/site/implementation/clone/static/js/carousel.js
-
curl -L -o carousel.js https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/eventbrite/solution/site/implementation/clone/static/js/carousel.js
1.24 kB
| // Destination carousel arrows: scroll the strip one viewport per click and | |
| // reflect scroll position in the disabled states. The strip itself is an | |
| // ordinary horizontally scrollable list without JS. | |
| (function () { | |
| "use strict"; | |
| document.querySelectorAll("[data-carousel-arrows]").forEach(function (bar) { | |
| var name = bar.getAttribute("data-carousel-arrows"); | |
| var strip = document.querySelector('[data-carousel="' + name + '"]'); | |
| if (!strip) return; | |
| bar.hidden = false; | |
| var prev = bar.querySelector("[data-carousel-prev]"); | |
| var next = bar.querySelector("[data-carousel-next]"); | |
| function step() { | |
| return Math.max(strip.clientWidth * 0.8, 240); | |
| } | |
| function sync() { | |
| var max = strip.scrollWidth - strip.clientWidth - 4; | |
| prev.disabled = strip.scrollLeft <= 4; | |
| next.disabled = strip.scrollLeft >= max; | |
| } | |
| prev.addEventListener("click", function () { | |
| strip.scrollBy({ left: -step(), behavior: "smooth" }); | |
| }); | |
| next.addEventListener("click", function () { | |
| strip.scrollBy({ left: step(), behavior: "smooth" }); | |
| }); | |
| strip.addEventListener("scroll", sync, { passive: true }); | |
| window.addEventListener("resize", sync); | |
| sync(); | |
| }); | |
| })(); | |