Last active
March 8, 2024 12:07
-
-
Save danielres/f891894cfeb0d110d3668edc52582361 to your computer and use it in GitHub Desktop.
Svelte flash animation for new elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Svelte flash animation for new elements | |
// source: https://learn.svelte.dev/tutorial/svelte-options | |
export default function flash(element) { | |
requestAnimationFrame(() => { | |
element.style.transition = 'none'; | |
element.style.color = 'rgba(255,62,0,1)'; | |
element.style.backgroundColor = 'rgba(255,62,0,0.2)'; | |
setTimeout(() => { | |
element.style.transition = 'color 1s, background 1s'; | |
element.style.color = ''; | |
element.style.backgroundColor = ''; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment