|
@@ -68,6 +68,63 @@
|
|
|
start();
|
|
start();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function setupHeroWheelAdvance() {
|
|
|
|
|
+ var shell = document.querySelector('.portal-shell.screen-shell');
|
|
|
|
|
+ var hero = document.querySelector('.gjjx-hero');
|
|
|
|
|
+ var target = document.querySelector('#gjjx-news');
|
|
|
|
|
+ if (!shell || !hero || !target) return;
|
|
|
|
|
+ var desktopMedia = window.matchMedia('(min-width: 901px)');
|
|
|
|
|
+ var reducedMotionMedia = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
|
|
|
+ var isAnimating = false;
|
|
|
|
|
+ var unlockTimer = 0;
|
|
|
|
|
+ var revealOffset = 16;
|
|
|
|
|
+
|
|
|
|
|
+ function pageOffset() {
|
|
|
|
|
+ return window.pageYOffset || document.documentElement.scrollTop || 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ function targetTop() {
|
|
|
|
|
+ return target.getBoundingClientRect().top + pageOffset();
|
|
|
|
|
+ }
|
|
|
|
|
+ function headerOffset() {
|
|
|
|
|
+ var header = document.querySelector('.screen-site-header');
|
|
|
|
|
+ return header ? Math.min(header.offsetHeight || 0, 88) : 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ function eligible(event) {
|
|
|
|
|
+ if (!desktopMedia.matches || reducedMotionMedia.matches || isAnimating) return false;
|
|
|
|
|
+ if (document.body.classList.contains('drawer-open')) return false;
|
|
|
|
|
+ if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return false;
|
|
|
|
|
+ return Math.abs(event.deltaY) >= Math.abs(event.deltaX);
|
|
|
|
|
+ }
|
|
|
|
|
+ function shouldAdvance(event) {
|
|
|
|
|
+ if (!eligible(event) || event.deltaY <= 0) return false;
|
|
|
|
|
+ var offset = pageOffset();
|
|
|
|
|
+ var newsTop = targetTop();
|
|
|
|
|
+ var heroBottom = hero.getBoundingClientRect().bottom + offset;
|
|
|
|
|
+ return offset < newsTop - 36 && offset < heroBottom - 80;
|
|
|
|
|
+ }
|
|
|
|
|
+ function shouldReturn(event) {
|
|
|
|
|
+ if (!eligible(event) || event.deltaY >= 0) return false;
|
|
|
|
|
+ var offset = pageOffset();
|
|
|
|
|
+ var fromTop = targetTop() - headerOffset() + revealOffset;
|
|
|
|
|
+ return offset > 120 && offset <= fromTop + Math.max(220, window.innerHeight * 0.34);
|
|
|
|
|
+ }
|
|
|
|
|
+ function scrollToPosition(top) {
|
|
|
|
|
+ isAnimating = true;
|
|
|
|
|
+ window.clearTimeout(unlockTimer);
|
|
|
|
|
+ window.scrollTo({ top: Math.max(0, top), behavior: 'smooth' });
|
|
|
|
|
+ unlockTimer = window.setTimeout(function () { isAnimating = false; }, 980);
|
|
|
|
|
+ }
|
|
|
|
|
+ window.addEventListener('wheel', function (event) {
|
|
|
|
|
+ if (shouldAdvance(event)) {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ scrollToPosition(targetTop() - headerOffset() + revealOffset);
|
|
|
|
|
+ } else if (shouldReturn(event)) {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ scrollToPosition(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, { passive: false });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function setupSlides(rootSelector, slideSelector, dotSelector, prevSelector, nextSelector) {
|
|
function setupSlides(rootSelector, slideSelector, dotSelector, prevSelector, nextSelector) {
|
|
|
var root = document.querySelector(rootSelector);
|
|
var root = document.querySelector(rootSelector);
|
|
|
if (!root) return;
|
|
if (!root) return;
|
|
@@ -107,6 +164,7 @@
|
|
|
start();
|
|
start();
|
|
|
}
|
|
}
|
|
|
setupHeroCarousel();
|
|
setupHeroCarousel();
|
|
|
|
|
+ setupHeroWheelAdvance();
|
|
|
setupSlides('[data-gjjx-news-carousel]', '[data-gjjx-news-slide]', '[data-gjjx-news-dot]', null, null);
|
|
setupSlides('[data-gjjx-news-carousel]', '[data-gjjx-news-slide]', '[data-gjjx-news-dot]', null, null);
|
|
|
})();
|
|
})();
|
|
|
|
|
|