fix: 修复页面内存泄漏问题
- 移除 initThemeTransition 中的 MutationObserver(会导致无限循环) - 移除 will-change 属性(大量元素使用会占用过多内存) - 主题切换过渡效果已在 setDarkmode() 函数中实现,无需重复
This commit is contained in:
@@ -3710,18 +3710,10 @@ void 0;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 主题切换动画
|
// 7. 主题切换动画 - 已在 header.php 中通过 setDarkmode 函数处理,此处不再重复
|
||||||
function initThemeTransition() {
|
function initThemeTransition() {
|
||||||
var observer = new MutationObserver(function(mutations) {
|
// 移除 MutationObserver 避免无限循环导致内存泄漏
|
||||||
mutations.forEach(function(mutation) {
|
// 主题切换过渡效果已在 setDarkmode() 函数中实现
|
||||||
if (mutation.attributeName === 'class') {
|
|
||||||
var html = document.documentElement;
|
|
||||||
html.classList.add('theme-transitioning');
|
|
||||||
setTimeout(function() { html.classList.remove('theme-transitioning'); }, 300);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 减少动画偏好检测
|
// 8. 减少动画偏好检测
|
||||||
|
|||||||
@@ -16327,7 +16327,6 @@ html.darkmode {
|
|||||||
@media (hover: hover) and (pointer: fine) {
|
@media (hover: hover) and (pointer: fine) {
|
||||||
article.post.card {
|
article.post.card {
|
||||||
transition: transform var(--animation-normal) var(--ease-out-expo), box-shadow var(--animation-normal) var(--ease-standard);
|
transition: transform var(--animation-normal) var(--ease-out-expo), box-shadow var(--animation-normal) var(--ease-standard);
|
||||||
will-change: transform, box-shadow;
|
|
||||||
}
|
}
|
||||||
article.post.card:hover {
|
article.post.card:hover {
|
||||||
transform: translateY(-6px) scale(1.005);
|
transform: translateY(-6px) scale(1.005);
|
||||||
@@ -16340,7 +16339,6 @@ html.darkmode {
|
|||||||
}
|
}
|
||||||
article.post.card .post-thumbnail {
|
article.post.card .post-thumbnail {
|
||||||
transition: transform var(--animation-slow) var(--ease-out-expo);
|
transition: transform var(--animation-slow) var(--ease-out-expo);
|
||||||
will-change: transform;
|
|
||||||
}
|
}
|
||||||
article.post.card:hover .post-thumbnail {
|
article.post.card:hover .post-thumbnail {
|
||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
|
|||||||
Reference in New Issue
Block a user