mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-30 07:28:38 +01:00
Amélioration de la transition de thème avec une animation de clipPath et ajustement des éléments pseudo pour le mode sombre
This commit is contained in:
@@ -21,23 +21,28 @@ function startViewTransition(event: MouseEvent | { clientX: number, clientY: num
|
|||||||
Math.max(y, window.innerHeight - y),
|
Math.max(y, window.innerHeight - y),
|
||||||
)
|
)
|
||||||
|
|
||||||
const transition = document.startViewTransition(() => {
|
const transition = document.startViewTransition(async () => {
|
||||||
switchTheme()
|
switchTheme()
|
||||||
|
await nextTick()
|
||||||
})
|
})
|
||||||
|
|
||||||
transition.ready.then(() => {
|
transition.ready.then(() => {
|
||||||
const duration = 500
|
const clipPath = [
|
||||||
|
`circle(0px at ${x}px ${y}px)`,
|
||||||
|
`circle(${endRadius}px at ${x}px ${y}px)`,
|
||||||
|
]
|
||||||
document.documentElement.animate(
|
document.documentElement.animate(
|
||||||
{
|
{
|
||||||
clipPath: [
|
clipPath: colorMode.value === 'dark'
|
||||||
`circle(0px at ${x}px ${y}px)`,
|
? [...clipPath].reverse()
|
||||||
`circle(${endRadius}px at ${x}px ${y}px)`,
|
: clipPath,
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
duration,
|
duration: 500,
|
||||||
easing: 'cubic-bezier(.76,.32,.29,.66)',
|
easing: 'ease-out',
|
||||||
pseudoElement: '::view-transition-new(root)',
|
pseudoElement: colorMode.value === 'dark'
|
||||||
|
? '::view-transition-old(root)'
|
||||||
|
: '::view-transition-new(root)',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user