|
@@ -33,4 +33,23 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // 固定“下一篇文章”按钮功能(仅首页存在)
|
|
|
|
|
+ const nextBtn = document.getElementById('nextArticleBtn');
|
|
|
|
|
+ if (nextBtn) {
|
|
|
|
|
+ nextBtn.addEventListener('click', function () {
|
|
|
|
|
+ const cards = document.querySelectorAll('.card');
|
|
|
|
|
+ if (!cards.length) return;
|
|
|
|
|
+ // 找到第一个顶部在视口下方(或刚好可见)的卡片
|
|
|
|
|
+ for (const card of cards) {
|
|
|
|
|
+ const rect = card.getBoundingClientRect();
|
|
|
|
|
+ if (rect.top >= 1) {
|
|
|
|
|
+ card.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 没有在下方可见的卡片,滚动到最后一篇
|
|
|
|
|
+ cards[cards.length - 1].scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|