feat: Wait for a new frame before animating workspace backgrounds, b=(no-bug), c=workspaces

This commit is contained in:
mr. m
2025-05-22 10:23:52 +02:00
parent f40b780b95
commit 50ed1f0a64

View File

@@ -2098,7 +2098,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
}
document.documentElement.setAttribute('animating-background', 'true');
if (shouldAnimate) {
if (shouldAnimate && previousWorkspace) {
let previousBackgroundOpacity = document.documentElement.style.getPropertyValue(
'--zen-background-opacity'
);
@@ -2114,19 +2114,24 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
previousBackgroundOpacity = 0;
}
gZenThemePicker.previousBackgroundOpacity = previousBackgroundOpacity;
animations.push(
gZenUIManager.motion.animate(
document.documentElement,
{
'--zen-background-opacity': [previousBackgroundOpacity, 1],
},
{
type: 'spring',
bounce: 0,
duration: kGlobalAnimationDuration,
}
)
);
await new Promise((resolve) => {
requestAnimationFrame(() => {
animations.push(
gZenUIManager.motion.animate(
document.documentElement,
{
'--zen-background-opacity': [previousBackgroundOpacity, 1],
},
{
type: 'spring',
bounce: 0,
duration: kGlobalAnimationDuration,
}
)
);
resolve();
});
});
}
for (const element of document.querySelectorAll('zen-workspace')) {
if (element.classList.contains('zen-essentials-container')) {