From b0822b1513017d09e1f05e5ffa48f06c627b9bf4 Mon Sep 17 00:00:00 2001 From: Adam French Date: Wed, 16 Sep 2026 15:32:03 +0100 Subject: [PATCH] update intro --- vue/src/views/home/Intro2.vue | 155 +++++++++++++++++----------------- 1 file changed, 76 insertions(+), 79 deletions(-) diff --git a/vue/src/views/home/Intro2.vue b/vue/src/views/home/Intro2.vue index a670224..49a7516 100644 --- a/vue/src/views/home/Intro2.vue +++ b/vue/src/views/home/Intro2.vue @@ -3,46 +3,43 @@ import { rand } from "@vueuse/core"; import { ref, onMounted, onUnmounted, nextTick } from "vue"; interface Item { - x: number; - y: number; - dx: number; - dy: number; - content: string; + x: number; + y: number; + dx: number; + dy: number; + content: string; } const container = ref(null); const itemEls = ref([]); const phrases = [ - "Welcome to my website", - "I'm looking to do a big revamp", - "A4 sheets of paper are what I'm used to", - "I'd love to know your recommendations", - "for very short books", - "Message me by any means necessary", - "I like anime, all kinds of music and sci fic", + "Welcome to my website", + "<3 thx for visiting", + "please get it touch ^_^", + "reccomend me your music :P", ]; // Non-reactive animation state to avoid triggering Vue re-renders every frame const animState = phrases.map((text, i) => ({ - x: 0, - y: i * 20, - dx: rand(0, 60) / 100, - dy: 1.0, - content: text, - cachedW: 0, - cachedH: 0, + x: 0, + y: i * 20, + dx: rand(0, 60) / 100, + dy: 1.0, + content: text, + cachedW: 0, + cachedH: 0, })); // Reactive items only for initial render const items = ref( - animState.map((s) => ({ - x: s.x, - y: s.y, - dx: s.dx, - dy: s.dy, - content: s.content, - })), + animState.map((s) => ({ + x: s.x, + y: s.y, + dx: s.dx, + dy: s.dy, + content: s.content, + })), ); let rafId = 0; @@ -52,76 +49,76 @@ let lastFrameTime = 0; const FRAME_INTERVAL = 1000 / 30; function measureSizes() { - const c = container.value; - if (c) { - cachedCW = c.clientWidth; - cachedCH = c.clientHeight; - } - itemEls.value.forEach((el, i) => { - if (el && animState[i]) { - animState[i].cachedW = el.offsetWidth; - animState[i].cachedH = el.offsetHeight; + const c = container.value; + if (c) { + cachedCW = c.clientWidth; + cachedCH = c.clientHeight; } - }); + itemEls.value.forEach((el, i) => { + if (el && animState[i]) { + animState[i].cachedW = el.offsetWidth; + animState[i].cachedH = el.offsetHeight; + } + }); } function animate(timestamp: number) { - if (!cachedCW || !cachedCH) { + if (!cachedCW || !cachedCH) { + rafId = requestAnimationFrame(animate); + return; + } + + if (timestamp - lastFrameTime < FRAME_INTERVAL) { + rafId = requestAnimationFrame(animate); + return; + } + lastFrameTime = timestamp; + + for (let i = 0; i < animState.length; i++) { + const s = animState[i]; + const el = itemEls.value[i]; + if (!el) continue; + + s.x += s.dx; + s.y += s.dy; + + if (s.x < 0 || s.x > cachedCW - s.cachedW) s.dx *= -1; + if (s.y < 0 || s.y > cachedCH - s.cachedH) s.dy *= -1; + + el.style.transform = `translate(${s.x}px, ${s.y}px)`; + } + rafId = requestAnimationFrame(animate); - return; - } - - if (timestamp - lastFrameTime < FRAME_INTERVAL) { - rafId = requestAnimationFrame(animate); - return; - } - lastFrameTime = timestamp; - - for (let i = 0; i < animState.length; i++) { - const s = animState[i]; - const el = itemEls.value[i]; - if (!el) continue; - - s.x += s.dx; - s.y += s.dy; - - if (s.x < 0 || s.x > cachedCW - s.cachedW) s.dx *= -1; - if (s.y < 0 || s.y > cachedCH - s.cachedH) s.dy *= -1; - - el.style.transform = `translate(${s.x}px, ${s.y}px)`; - } - - rafId = requestAnimationFrame(animate); } let resizeObserver: ResizeObserver; onMounted(async () => { - await nextTick(); - measureSizes(); - rafId = requestAnimationFrame(animate); + await nextTick(); + measureSizes(); + rafId = requestAnimationFrame(animate); - resizeObserver = new ResizeObserver(measureSizes); - resizeObserver.observe(container.value!); + resizeObserver = new ResizeObserver(measureSizes); + resizeObserver.observe(container.value!); }); onUnmounted(() => { - cancelAnimationFrame(rafId); - resizeObserver?.disconnect(); + cancelAnimationFrame(rafId); + resizeObserver?.disconnect(); });