fired transitions run animation once

This commit is contained in:
Joeri Exelmans 2025-10-21 14:23:25 +02:00
parent 0ba4fd4cae
commit 29808a683c
6 changed files with 34 additions and 14 deletions

View file

@ -119,6 +119,21 @@ export function VisualEditor({state, setState, ast, setAST, rt, errors, setError
}
}, []);
useEffect(() => {
// bit of a hacky way to force the animation on fired transitions to replay, if the new 'rt' contains the same fired transitions as the previous one
requestAnimationFrame(() => {
console.log('rt changed');
document.querySelectorAll(".arrow.fired").forEach(el => {
el.style.animation = 'none';
requestAnimationFrame(() => {
el.style.animation = '';
})
setTimeout(() => {
}, 10); // <- small timeout seems to be necessary or the animation won't restart
});
})
}, [rt]);
useEffect(() => {
const timeout = setTimeout(() => {
const serializedState = JSON.stringify(state);