Skip to content

Commit

Permalink
Restart animation on viewport change
Browse files Browse the repository at this point in the history
  • Loading branch information
ernstmul committed Dec 27, 2024
1 parent fbf10a4 commit 82d64af
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/routes/(console)/onboarding/create-project/loading.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
let currentSentenceIndex = 0;
let visible = true;
function handleResize() {
startAnimation = false;
setTimeout(() => {
startAnimation = true;
}, 1500);
}
onMount(() => {
window.addEventListener('resize', handleResize);
const interval = setInterval(() => {
visible = false;
currentSentenceIndex = (currentSentenceIndex + 1) % loadingSentences.length;
Expand All @@ -19,7 +27,10 @@
}, 1000);
}, 5000);
return () => clearInterval(interval);
return () => {
clearInterval(interval);
window.removeEventListener('resize', handleResize);
};
});
</script>

Expand Down

0 comments on commit 82d64af

Please sign in to comment.