This commit is contained in:
2026-02-06 13:37:22 +01:00
parent 44a88dcfad
commit 73f47b161c
2 changed files with 36 additions and 12 deletions

View File

@@ -16,7 +16,7 @@
maxOpacity: 0.6,
magnetRadius: 200,
maxDisplacement: 12,
returnSpeed: 0.1,
returnSpeed: 0.25, // Faster return to prevent color lag
// Base color (neutral gray)
baseR: 119, baseG: 119, baseB: 100,
// Colors for proximity effect (teal to orange)
@@ -170,8 +170,12 @@
const horizSpacing = CONFIG.hexSize * Math.sqrt(3);
const vertSpacing = CONFIG.hexSize * 1.5;
const cols = Math.ceil(window.innerWidth / horizSpacing) + 3;
const rows = Math.ceil(window.innerHeight / vertSpacing) + 3;
// Use full screen dimensions
const width = Math.max(window.innerWidth, document.documentElement.clientWidth);
const height = Math.max(window.innerHeight, document.documentElement.clientHeight);
const cols = Math.ceil(width / horizSpacing) + 4;
const rows = Math.ceil(height / vertSpacing) + 4;
for (let row = -1; row < rows; row++) {
for (let col = -1; col < cols; col++) {
@@ -193,10 +197,17 @@
function resize() {
const dpr = window.devicePixelRatio || 1;
canvas.width = window.innerWidth * dpr;
canvas.height = window.innerHeight * dpr;
canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';
// Use full document dimensions to cover entire scrollable page
const width = Math.max(window.innerWidth, document.documentElement.clientWidth);
const height = Math.max(window.innerHeight, document.documentElement.clientHeight);
canvas.width = width * dpr;
canvas.height = height * dpr;
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
// Reset transform and apply new scale
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.scale(dpr, dpr);
}
@@ -226,8 +237,12 @@
const dx = mouse.x - hex.originX;
const dy = mouse.y - hex.originY;
const distance = Math.sqrt(dx * dx + dy * dy);
// Check if position OR color needs to return to default
const isReturning = Math.abs(hex.currentX - hex.originX) > 0.1 ||
Math.abs(hex.currentY - hex.originY) > 0.1;
Math.abs(hex.currentY - hex.originY) > 0.1 ||
hex.colorInfluence > 0.01 ||
hex.opacity > CONFIG.baseOpacity + 0.01;
if (distance < updateRadius || isReturning) {
hex.update(mouse.x, mouse.y);