加入昼夜切换的动画优化
This commit is contained in:
1 parent
1cae1da5ec
commit
2b53592adc
3 files changed
+13
-31
No files matched your search
@@ -69,7 +69,7 @@ hasCJKLanguage = true
|
|||||||
# 自定义文章固定链接 (Permalinks)
|
# 自定义文章固定链接 (Permalinks)
|
||||||
# 使用日期作为文件名,例如 /20260117.html
|
# 使用日期作为文件名,例如 /20260117.html
|
||||||
[permalinks]
|
[permalinks]
|
||||||
post = "/:slug"
|
posts = "/:slug"
|
||||||
|
|
||||||
# 确保日期优先使用 Front Matter 中的 date
|
# 确保日期优先使用 Front Matter 中的 date
|
||||||
[frontmatter]
|
[frontmatter]
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
function themeSweep(newTheme, callback) {
|
function themeSweep(newTheme, callback) {
|
||||||
// View Transition API — browser-native crossfade, zero JS animation overhead.
|
// View Transition API — best quality if available
|
||||||
// Same principle as image lightbox transitions. Chrome/Edge 111+, Opera 97+.
|
|
||||||
if (document.startViewTransition) {
|
if (document.startViewTransition) {
|
||||||
document.startViewTransition(function() { callback(); });
|
document.startViewTransition(function() { callback(); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: lightweight overlay for Safari / Firefox
|
// UIkit animate fallback
|
||||||
var oldTheme = document.documentElement.getAttribute('data-theme');
|
if (window.UIkit && UIkit.animate) {
|
||||||
var tint = oldTheme === 'dark'
|
var body = document.body;
|
||||||
? 'rgba(15,23,42,0.95)'
|
UIkit.animate(body, 'uk-animation-fade uk-animation-fast');
|
||||||
: 'rgba(255,255,255,0.95)';
|
setTimeout(function() {
|
||||||
|
callback();
|
||||||
var overlay = document.createElement('div');
|
UIkit.animate(body, 'uk-animation-fade uk-animation-fast');
|
||||||
overlay.style.cssText =
|
}, 150);
|
||||||
'position:fixed;inset:0;z-index:9999;pointer-events:none;' +
|
return;
|
||||||
'background:' + tint + ';opacity:1;' +
|
|
||||||
'transition:opacity 0.22s ease;' +
|
|
||||||
'will-change:opacity;contain:paint;';
|
|
||||||
document.body.appendChild(overlay);
|
|
||||||
|
|
||||||
var cleaned = false;
|
|
||||||
function cleanup() {
|
|
||||||
if (cleaned) return;
|
|
||||||
cleaned = true;
|
|
||||||
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Last resort: simple opacity
|
||||||
callback();
|
callback();
|
||||||
overlay.offsetWidth;
|
|
||||||
overlay.style.opacity = '0';
|
|
||||||
|
|
||||||
overlay.addEventListener('transitionend', function(e) {
|
|
||||||
if (e.propertyName !== 'opacity') return;
|
|
||||||
cleanup();
|
|
||||||
});
|
|
||||||
setTimeout(cleanup, 380);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toast Message Helper
|
// Toast Message Helper
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
- 简介:{{ .Site.Params.message_info.description | default .Site.Params.author.description }}<br>
|
- 简介:{{ .Site.Params.message_info.description | default .Site.Params.author.description }}<br>
|
||||||
- 链接:{{ .Site.Params.message_info.url | default .Site.BaseURL }}<br>
|
- 链接:{{ .Site.Params.message_info.url | default .Site.BaseURL }}<br>
|
||||||
- 图标:{{ .Site.Params.message_info.icon | default .Site.Params.author.avatar }}<br>
|
- 图标:{{ .Site.Params.message_info.icon | default .Site.Params.author.avatar }}<br>
|
||||||
- 订阅:{{ .Site.BaseURL }}rss.xml
|
- 订阅:{{ "rss.xml" | absURL }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="uk-divider-icon">
|
<hr class="uk-divider-icon">
|
||||||
|
|||||||
Reference in new issue
Block a user