From dbf2efc957489b4ffb8c23735b7d4eaf19e0f253 Mon Sep 17 00:00:00 2001 From: brulijam Date: Mon, 25 Nov 2024 00:50:16 +0100 Subject: [PATCH] small fixes --- src/css/main.css | 5 ++--- src/js/background.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/css/main.css b/src/css/main.css index 3969538..06d976c 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -116,14 +116,13 @@ header .names { header h1, header p { text-align: left; - font-size: 35px; color: var(--color-primary); font-family: pilowlava, monospace; } header p { font-family: space-mono, monospace; - font-size: 25px; + font-size: 20px; } header img { @@ -134,7 +133,7 @@ header img { /* Description */ header, .description, .linkGroup, .timer, footer { - background-color: rgba(15, 0, 10, 0.9); + background-color: rgba(15, 0, 10, 0.8); /*border: 1px var(--color-primary) solid;*/ border: 1px var(--color-accent-c) solid; } diff --git a/src/js/background.js b/src/js/background.js index e1cbd01..59a7642 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -86,10 +86,29 @@ document.addEventListener('DOMContentLoaded', () => { const color = Math.random() > 0.5 ? '_red' : ''; createBlob(blobContainer, 'line', `blob-freeform-${x}${color}.svg`, zIndexCounter - 1, position); } + + if (isMobileView()) { + toggleMouseEffects(false); + } else { + toggleMouseEffects(true); + } }); -document.addEventListener('mousemove', (event) => { + +function isMobileView() { + return window.innerWidth <= 480; +} + +function toggleMouseEffects(enable) { + if (enable) { + document.addEventListener('mousemove', handleMouseMovement); + } else { + document.removeEventListener('mousemove', handleMouseMovement); + } +} + +function handleMouseMovement(event) { const elements = [...document.querySelectorAll('.solid, .line')]; const { clientX: mouseX, clientY: mouseY } = event; const { innerWidth: width, innerHeight: height } = window; @@ -102,4 +121,12 @@ document.addEventListener('mousemove', (event) => { const rotation = element.dataset.rotation || 0; element.style.transform = `translate(-50%, -50%) translate(${xOffset / strength}px, ${yOffset / strength}px) rotate(${rotation}deg)`; }); +} + +window.addEventListener('resize', () => { + if (isMobileView()) { + toggleMouseEffects(false); + } else { + toggleMouseEffects(true); + } }); \ No newline at end of file