This commit is contained in:
2026-02-05 11:53:21 +01:00
parent afcbd07d56
commit 1ff8454432
37 changed files with 5462 additions and 3491 deletions

View File

@@ -27,27 +27,57 @@ document.addEventListener("DOMContentLoaded", function () {
body.classList.add('system-cursor');
if (toggleBtn) {
toggleBtn.classList.remove('active');
const icon = toggleBtn.querySelector('.cursor-icon');
let icon = toggleBtn.querySelector('.cursor-icon');
if (icon) {
// Check if we're on a page in the sites/ folder
const currentPath = window.location.pathname;
const isInSitesFolder = currentPath.includes('/sites/');
const imagePath = isInSitesFolder ? '../images/additional/spidy.png' : 'images/additional/spidy.png';
icon.src = imagePath;
// Replace img with spidy.png if needed
if (icon.tagName !== 'IMG') {
const newIcon = document.createElement('img');
newIcon.className = 'cursor-icon';
newIcon.alt = 'Spider Cursor';
// Check if we're on a page in the sites/ folder
const currentPath = window.location.pathname;
const isInSitesFolder = currentPath.includes('/sites/');
const imagePath = isInSitesFolder ? '../images/additional/spidy.png' : 'images/additional/spidy.png';
newIcon.src = imagePath;
icon.parentNode.replaceChild(newIcon, icon);
} else {
// Update existing img
const currentPath = window.location.pathname;
const isInSitesFolder = currentPath.includes('/sites/');
const imagePath = isInSitesFolder ? '../images/additional/spidy.png' : 'images/additional/spidy.png';
icon.src = imagePath;
}
}
}
} else {
// Custom cursor (secondary) - show cursor icon
// Custom cursor (secondary) - show standard cursor icon
body.classList.remove('system-cursor');
if (toggleBtn) {
toggleBtn.classList.add('active');
const icon = toggleBtn.querySelector('.cursor-icon');
let icon = toggleBtn.querySelector('.cursor-icon');
if (icon) {
// Check if we're on a page in the sites/ folder
const currentPath = window.location.pathname;
const isInSitesFolder = currentPath.includes('/sites/');
const imagePath = isInSitesFolder ? '../images/additional/cursor.png' : 'images/additional/cursor.png';
icon.src = imagePath;
// Replace img with cursor.png if needed
if (icon.tagName !== 'IMG') {
const newIcon = document.createElement('img');
newIcon.className = 'cursor-icon';
newIcon.alt = 'Custom Cursor';
// Check if we're on a page in the sites/ folder
const currentPath = window.location.pathname;
const isInSitesFolder = currentPath.includes('/sites/');
const imagePath = isInSitesFolder ? '../images/additional/cursor.png' : 'images/additional/cursor.png';
newIcon.src = imagePath;
icon.parentNode.replaceChild(newIcon, icon);
} else {
// Update existing img
const currentPath = window.location.pathname;
const isInSitesFolder = currentPath.includes('/sites/');
const imagePath = isInSitesFolder ? '../images/additional/cursor.png' : 'images/additional/cursor.png';
icon.src = imagePath;
}
}
}
}
@@ -63,29 +93,40 @@ document.addEventListener("DOMContentLoaded", function () {
});
}
const canvas = document.createElement("canvas");
canvas.id = "venom-cursor";
document.body.appendChild(canvas);
function initCursor() {
const canvas = document.createElement("canvas");
canvas.id = "venom-cursor";
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d");
const width = window.innerWidth;
const height = window.innerHeight;
canvas.width = width;
canvas.height = height;
const tentacles = [];
const mouse = { x: 0, y: 0 };
const oldMouse = { x: 0, y: 0 };
document.addEventListener("mousemove", (e) => {
mouse.x = e.clientX;
mouse.y = e.clientY;
});
window.addEventListener("resize", () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
return { canvas, ctx, tentacles, mouse, oldMouse };
}
const ctx = canvas.getContext("2d");
const width = window.innerWidth;
const height = window.innerHeight;
canvas.width = width;
canvas.height = height;
const tentacles = [];
const mouse = { x: 0, y: 0 };
const oldMouse = { x: 0, y: 0 };
document.addEventListener("mousemove", (e) => {
mouse.x = e.clientX;
mouse.y = e.clientY;
});
window.addEventListener("resize", () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
const cursorElements = initCursor();
const canvas = cursorElements.canvas;
const ctx = cursorElements.ctx;
const tentacles = cursorElements.tentacles;
const mouse = cursorElements.mouse;
const oldMouse = cursorElements.oldMouse;
class Tentacle {
constructor(mx, my, targetX, targetY) {
@@ -130,7 +171,12 @@ document.addEventListener("DOMContentLoaded", function () {
}
function render() {
ctx.clearRect(0, 0, width, height);
if (isCursorDisabled) {
requestAnimationFrame(render);
return;
}
ctx.clearRect(0, 0, canvas.width, canvas.height);
// 1. Create new tentacles on movement
const distMoved = Math.hypot(mouse.x - oldMouse.x, mouse.y - oldMouse.y);