The editors' meeting has been canceled for technical reasons.
MediaWiki:Common.js:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 标签:已被回退 |
无编辑摘要 标签:已被回退 |
||
第13行: | 第13行: | ||
const y = event.clientY - rect.top - rect.height / 2; | const y = event.clientY - rect.top - rect.height / 2; | ||
// | // 计算目标角度并限制在±10度,速度减慢3倍 | ||
const targetX = Math.max(-10, Math.min(10, -y / | const targetX = Math.max(-10, Math.min(10, -y / 60)); // 速度减慢 | ||
const targetY = Math.max(-10, Math.min(10, x / | const targetY = Math.max(-10, Math.min(10, x / 60)); // 速度减慢 | ||
// 使用缓动算法逐步接近目标角度 | // 使用缓动算法逐步接近目标角度 | ||
第21行: | 第21行: | ||
currentY += (targetY - currentY) * 0.1; | currentY += (targetY - currentY) * 0.1; | ||
// | // 计算颜色深度 | ||
rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg) | const distance = Math.sqrt(x * x + y * y); | ||
const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2); | |||
const colorIntensity = Math.max(0, 1 - (distance / maxDistance) * 0.5); | |||
// 应用3D旋转和背景颜色变化 | |||
rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`; | |||
rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, ${colorIntensity})`; | |||
}); | }); | ||
第30行: | 第36行: | ||
currentY = 0; | currentY = 0; | ||
rotatingDiv.style.transform = `rotateX(0deg) rotateY(0deg)`; | rotatingDiv.style.transform = `rotateX(0deg) rotateY(0deg)`; | ||
rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, 1)`; | |||
}); | }); | ||
} | } |
2024年10月28日 (一) 21:49的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ // 检查当前页面是否为首页 if (mw.config.get('wgPageName') === '首页') { // 在指定页面上运行的JavaScript代码 const rotatingDiv = document.getElementById('rotatingDiv'); let currentX = 0; let currentY = 0; rotatingDiv.addEventListener('mousemove', (event) => { const rect = rotatingDiv.getBoundingClientRect(); const x = event.clientX - rect.left - rect.width / 2; const y = event.clientY - rect.top - rect.height / 2; // 计算目标角度并限制在±10度,速度减慢3倍 const targetX = Math.max(-10, Math.min(10, -y / 60)); // 速度减慢 const targetY = Math.max(-10, Math.min(10, x / 60)); // 速度减慢 // 使用缓动算法逐步接近目标角度 currentX += (targetX - currentX) * 0.1; currentY += (targetY - currentY) * 0.1; // 计算颜色深度 const distance = Math.sqrt(x * x + y * y); const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2); const colorIntensity = Math.max(0, 1 - (distance / maxDistance) * 0.5); // 应用3D旋转和背景颜色变化 rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`; rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, ${colorIntensity})`; }); rotatingDiv.addEventListener('mouseleave', () => { // 鼠标离开时恢复初始状态 currentX = 0; currentY = 0; rotatingDiv.style.transform = `rotateX(0deg) rotateY(0deg)`; rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, 1)`; }); }