Add custom theme animation instead of transition view

This commit is contained in:
2024-06-24 23:50:34 +02:00
parent c69c462f34
commit 72bcc01073

View File

@@ -31,13 +31,14 @@ const navs = [
] ]
function toggleTheme() { function toggleTheme() {
if (!document.startViewTransition) { document.body.style.animation = 'theme-switch-on .5s'
setTimeout(() => {
isDark.value = !isDark.value isDark.value = !isDark.value
return document.body.style.animation = 'theme-switch-off .5s'
} setTimeout(() => {
document.body.style.animation = ''
document.startViewTransition(() => { }, 500)
}) }, 500)
} }
</script> </script>
@@ -84,4 +85,26 @@ function toggleTheme() {
.handwriting { .handwriting {
font-family: 'Dancing Script', cursive; font-family: 'Dancing Script', cursive;
} }
@keyframes theme-switch-on {
0% {
filter: blur(0);
transform: scale(1);
}
100% {
transform: scale(0.98);
filter: blur(3px);
}
}
@keyframes theme-switch-off {
0% {
transform: scale(0.98);
filter: blur(3px);
}
100% {
filter: blur(0);
transform: scale(1);
}
}
</style> </style>