/** * AKSRT Enhancements — 全局 UI 增强 * * 图片灯箱由 assets/js/runtime/imgbox.js(Miniimgbox,zibll 风格)唯一负责, * 此文件仅保留滚动方向感知的 legacy class 同步。 * * @package AKSRT */ (function () { 'use strict'; var initialized = false; /* ============================================================ * 滚动方向感知 * Scroll direction is owned by runtime main.js body scroll bus * (body.scroll-down / body.scroll-up / body.body-scroll). * This stub syncs the legacy aksrt-* prefixed classes for backward compat. * ============================================================ */ function initScrollDirection() { var body = document.body; function sync() { body.classList.toggle('aksrt-body-scroll', body.classList.contains('body-scroll')); body.classList.toggle('aksrt-scroll-down', body.classList.contains('scroll-down')); body.classList.toggle('aksrt-scroll-up', body.classList.contains('scroll-up')); body.classList.add('aksrt-scrolling'); clearTimeout(body._aksrtScrollTimer); body._aksrtScrollTimer = setTimeout(function () { body.classList.remove('aksrt-scrolling'); }, 300); } function onScroll() { requestAnimationFrame(sync); } window.addEventListener('scroll', onScroll, { passive: true }); } /* ============================================================ * 初始化入口 — 只执行一次(window scroll 绑定不可重复) * ============================================================ */ function init() { if (initialized) return; initialized = true; initScrollDirection(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();