| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // Art page — vanilla JS (no jQuery, no Bootstrap carousel).
- // Navbar hide/show on scroll (ported from the shared jQuery dw_hidenav).
- (function () {
- const navbar = document.querySelector('.navbar');
- if (!navbar) return;
- const title = document.querySelector('.site-title a');
- const headerHeight = navbar.offsetHeight;
- let previousTop = 0;
- window.addEventListener('scroll', function () {
- const currentTop = window.scrollY;
- if (currentTop < previousTop) {
- if (currentTop > 0 && navbar.classList.contains('fixed')) {
- navbar.classList.add('visible');
- if (title) title.classList.remove('light');
- } else {
- navbar.classList.remove('visible', 'fixed');
- }
- } else {
- navbar.classList.remove('visible');
- if (currentTop > headerHeight && !navbar.classList.contains('fixed')) {
- navbar.classList.add('fixed');
- }
- }
- previousTop = currentTop;
- }, { passive: true });
- })();
- // Gallery — scroll-snap prev/next buttons + arrow keys (replaces the BS carousel).
- (function () {
- const track = document.querySelector('.dw-carousel-track');
- if (!track) return;
- const step = () =>
- track.firstElementChild
- ? track.firstElementChild.getBoundingClientRect().width
- : track.clientWidth;
- const scroll = (dir) => track.scrollBy({ left: dir * step(), behavior: 'smooth' });
- const prev = document.querySelector('.dw-carousel-prev');
- const next = document.querySelector('.dw-carousel-next');
- if (prev) prev.addEventListener('click', () => scroll(-1));
- if (next) next.addEventListener('click', () => scroll(1));
- document.addEventListener('keydown', function (e) {
- if (e.key === 'ArrowRight') scroll(1);
- else if (e.key === 'ArrowLeft') scroll(-1);
- });
- })();
|