From c3a0c735fa28f22f2d08b24bddde61b08482ab52 Mon Sep 17 00:00:00 2001 From: BOTAlex Date: Sun, 31 Mar 2024 07:26:15 +0200 Subject: [PATCH] Bounce back to center if mouse leave --- src/routes/zhen/Comps/TopAnimatedBackground.svelte | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/routes/zhen/Comps/TopAnimatedBackground.svelte b/src/routes/zhen/Comps/TopAnimatedBackground.svelte index ab32c2c..e72bace 100644 --- a/src/routes/zhen/Comps/TopAnimatedBackground.svelte +++ b/src/routes/zhen/Comps/TopAnimatedBackground.svelte @@ -51,9 +51,15 @@ windowRef.addEventListener("resize", updateDimensions); + const RevertToOrigin = () => { + updateAnimation(new Vector2(windowWidth/2, windowHeight/2)); + }; + document.documentElement.addEventListener('mouseleave', RevertToOrigin) + return () => { windowRef.removeEventListener("resize", updateDimensions); }; + }); const programmingLanguages: string[] = [