From 1f5f7a3777f130514d154148662200f8f3c791ee Mon Sep 17 00:00:00 2001 From: BOTAlex Date: Tue, 2 Apr 2024 18:13:54 +0200 Subject: [PATCH] [Sync] Starting to use parallex again --- package-lock.json | 16 ++++ package.json | 1 + .../zhen/Comps/TopAnimatedBackground.svelte | 82 ++++++++++++++----- 3 files changed, 77 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc72c2b..13b1b84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "svelte": "^4.2.7", "svelte-check": "^3.6.0", "svelte-highlight": "^7.6.0", + "svelte-parallax": "^0.6.0", "typescript": "^5.0.0", "vite": "^5.0.3" } @@ -897,6 +898,12 @@ "node": ">=8.0" } }, + "node_modules/focus-options-polyfill": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/focus-options-polyfill/-/focus-options-polyfill-1.6.0.tgz", + "integrity": "sha512-uyrAmLZrPnUItQY5wTdg31TO9GGZRGsh/jmohUg9oLmLi/sw5y7LlTV/mwyd6rvbxIOGwmRiv6LcTS8w7Bk9NQ==", + "dev": true + }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -1794,6 +1801,15 @@ "resolved": "https://registry.npmjs.org/svelte-media-queries/-/svelte-media-queries-1.6.2.tgz", "integrity": "sha512-SMz6od/vIeZEGlc4P0HKJK4G0fZotuwFhCSpBQaPqh75h6sL6sNf+4+IjbegFKXbP7b+SOfyzVOIMXTr8jynkA==" }, + "node_modules/svelte-parallax": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/svelte-parallax/-/svelte-parallax-0.6.0.tgz", + "integrity": "sha512-W2dGPNmK274AmL8Ibzr96luh24jr3u2MfAmAJTpnhAZwxkRws5MKgCxfxBBPvpRUc2GpGGIGanhTYXoHV6DcBw==", + "dev": true, + "dependencies": { + "focus-options-polyfill": "^1.6.0" + } + }, "node_modules/svelte/node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", diff --git a/package.json b/package.json index 85b0370..bffde61 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "svelte": "^4.2.7", "svelte-check": "^3.6.0", "svelte-highlight": "^7.6.0", + "svelte-parallax": "^0.6.0", "typescript": "^5.0.0", "vite": "^5.0.3" }, diff --git a/src/routes/zhen/Comps/TopAnimatedBackground.svelte b/src/routes/zhen/Comps/TopAnimatedBackground.svelte index 9ccc3d9..72ec3aa 100644 --- a/src/routes/zhen/Comps/TopAnimatedBackground.svelte +++ b/src/routes/zhen/Comps/TopAnimatedBackground.svelte @@ -4,6 +4,8 @@ import TopNameTextPlate from "./TopNameTextPlate.svelte"; //import { throttle } from "./../Utils/Throttle"; + import { Parallax, ParallaxLayer, StickyLayer } from "svelte-parallax"; + // Params let mouseMoveScale: number = 0.25; let targetTextLenght: number = 100; @@ -52,24 +54,32 @@ windowRef.addEventListener("resize", updateDimensions); const RevertToOrigin = () => { - if(navigator.userAgent.search(/gecko/i)>0 && StartPageAnimated !== null){ - StartPageAnimated.classList.add('FirefoxSmoothTranition'); + if ( + navigator.userAgent.search(/gecko/i) > 0 && + StartPageAnimated !== null + ) { + StartPageAnimated.classList.add("FirefoxSmoothTranition"); } - updateAnimation(new Vector2(windowWidth/2, windowHeight/2)); + updateAnimation(new Vector2(windowWidth / 2, windowHeight / 2)); }; - document.documentElement.addEventListener('mouseleave', RevertToOrigin) + document.documentElement.addEventListener("mouseleave", RevertToOrigin); const RemoveFirefoxSmoothTranition = () => { - if(navigator.userAgent.search(/gecko/i)>0 && StartPageAnimated !== null){ - StartPageAnimated.classList.remove('FirefoxSmoothTranition'); + if ( + navigator.userAgent.search(/gecko/i) > 0 && + StartPageAnimated !== null + ) { + StartPageAnimated.classList.remove("FirefoxSmoothTranition"); } }; - document.documentElement.addEventListener('mouseenter', RemoveFirefoxSmoothTranition) + document.documentElement.addEventListener( + "mouseenter", + RemoveFirefoxSmoothTranition, + ); return () => { windowRef.removeEventListener("resize", updateDimensions); }; - }); const programmingLanguages: string[] = [ @@ -81,27 +91,52 @@ "JAVASCRIPT", "TYPESCRIPT", "HTML", - "CSS" + "CSS", ]; function getRandomInt(max: number) { return Math.floor(Math.random() * max); } - function GrabRandomString(){ + function GrabRandomString() { let outString: string = ""; while (outString.length < targetTextLenght) { - outString += programmingLanguages[getRandomInt(programmingLanguages.length)] + " "; + outString += + programmingLanguages[ + getRandomInt(programmingLanguages.length) + ] + " "; } return outString; // At about target size } - -
+ + +
+ {#each { length: 100 } as _, i} + + {GrabRandomString()} + + {/each} +
+
+ + + + + + + +
+ + -
+