fix(frontend): タブ間同期が行われるとテーマが切り替わり続ける問題を修正 (#16094)

This commit is contained in:
かっこかり 2025-05-25 08:37:39 +09:00 committed by GitHub
parent 02b37b7adf
commit fab9db405c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 14 deletions

View File

@ -101,27 +101,15 @@ html._themeChanging_ {
} }
html::view-transition-new(theme-changing) { html::view-transition-new(theme-changing) {
z-index: 4000001; z-index: 4000000;
animation: themeChangingNew 0.5s ease;
animation-fill-mode: forwards;
} }
html::view-transition-old(theme-changing) { html::view-transition-old(theme-changing) {
z-index: 4000000; z-index: 4000001;
animation: themeChangingOld 0.5s ease; animation: themeChangingOld 0.5s ease;
animation-fill-mode: forwards; animation-fill-mode: forwards;
} }
@keyframes themeChangingNew {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes themeChangingOld { @keyframes themeChangingOld {
0% { 0% {
opacity: 1; opacity: 1;

View File

@ -15,6 +15,7 @@ import { globalEvents } from '@/events.js';
import { miLocalStorage } from '@/local-storage.js'; import { miLocalStorage } from '@/local-storage.js';
import { $i } from '@/i.js'; import { $i } from '@/i.js';
import { prefer } from '@/preferences.js'; import { prefer } from '@/preferences.js';
import { deepEqual } from '@/utility/deep-equal.js';
export type Theme = { export type Theme = {
id: string; id: string;
@ -127,6 +128,7 @@ function applyThemeInternal(theme: Theme, persist: boolean) {
} }
let timeout: number | null = null; let timeout: number | null = null;
let currentTheme: Theme | null = null;
export function applyTheme(theme: Theme, persist = true) { export function applyTheme(theme: Theme, persist = true) {
if (timeout) { if (timeout) {
@ -134,6 +136,9 @@ export function applyTheme(theme: Theme, persist = true) {
timeout = null; timeout = null;
} }
if (deepEqual(currentTheme, theme)) return;
currentTheme = theme;
if (window.document.startViewTransition != null && prefer.s.animation) { if (window.document.startViewTransition != null && prefer.s.animation) {
window.document.documentElement.classList.add('_themeChanging_'); window.document.documentElement.classList.add('_themeChanging_');
window.document.startViewTransition(async () => { window.document.startViewTransition(async () => {