优化pjax刷新

This commit is contained in:
Vaica committed 2026-06-02 14:34:23 +08:00
1 parent cc5887a74d
commit cda4dbb24b
8 files changed
+65 -24

No files matched your search

+5 -6
View File
@@ -25,18 +25,17 @@
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
function initPostScrollspy() {
var content = document.getElementById('post-writing');
if (!content) return;
// 滚动时内容从下方淡入,符合"往下看"的直觉
content.querySelectorAll('h2, h3, h4, p, ul, ol, blockquote, table').forEach(function(el) {
el.setAttribute('uk-scrollspy', 'cls: uk-animation-fade; delay: 60');
if (!el.hasAttribute('uk-scrollspy')) el.setAttribute('uk-scrollspy', 'cls: uk-animation-fade; delay: 60');
});
// 图片/视频/链接卡片稍微带点位移,更有"出现感"
content.querySelectorAll('figure, img, .post-video, .link-card').forEach(function(el) {
el.setAttribute('uk-scrollspy', 'cls: uk-animation-slide-bottom-small; delay: 100');
if (!el.hasAttribute('uk-scrollspy')) el.setAttribute('uk-scrollspy', 'cls: uk-animation-slide-bottom-small; delay: 100');
});
});
}
document.addEventListener('DOMContentLoaded', initPostScrollspy);
</script>