fix(frontend): visibilityStateがhiddenな状態でstartViewTransitionしないように
This commit is contained in:
parent
128fe6d644
commit
e1b6e9d4b6
|
|
@ -144,7 +144,9 @@ export function applyTheme(theme: Theme, persist = true) {
|
|||
if (theme.id === currentThemeId && miLocalStorage.getItem('themeCachedVersion') === version) return;
|
||||
currentThemeId = theme.id;
|
||||
|
||||
if (window.document.startViewTransition != null) {
|
||||
// visibilityStateがhiddenな状態でstartViewTransitionするとブラウザによってはエラーになる
|
||||
// 通常hiddenな時に呼ばれることはないが、iOSのPWAだとアプリ切り替え時に(何故か)hiddenな状態で(何故か)一瞬デバイスのダークモード判定が変わりapplyThemeが呼ばれる場合がある
|
||||
if (window.document.startViewTransition != null && window.document.visibilityState === 'visible') {
|
||||
window.document.documentElement.classList.add('_themeChanging_');
|
||||
try {
|
||||
window.document.startViewTransition(async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue