Skip to content

Instantly share code, notes, and snippets.

@danielres
Last active March 8, 2024 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielres/f891894cfeb0d110d3668edc52582361 to your computer and use it in GitHub Desktop.
Save danielres/f891894cfeb0d110d3668edc52582361 to your computer and use it in GitHub Desktop.
Svelte flash animation for new elements
// 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