adds a hard coded delay to drastically reduce theme picker jank

This commit is contained in:
Cory LaViska
2025-03-24 16:40:17 -04:00
parent fcfe2bde7d
commit a4a257f8e7

View File

@@ -4,9 +4,12 @@ export function domChange(fn, { behavior = 'smooth' } = {}) {
document.startViewTransition && !window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (canUseViewTransitions && behavior === 'smooth') {
document.startViewTransition(fn);
} else {
fn(true);
const transition = document.startViewTransition(() => {
fn(true);
// Wait a brief delay before finishing the transition to prevent jumpiness
return new Promise(resolve => setTimeout(resolve, 200));
});
return transition;
}
}