The editors' meeting has been canceled for technical reasons.
MediaWiki:Common.js:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 标签:已被回退 |
无编辑摘要 标签:手工回退 已被回退 |
||
第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | |||
// 检查当前页面是否为首页 | // 检查当前页面是否为首页 | ||
if (mw.config.get('wgPageName') === '首页') { | if (mw.config.get('wgPageName') === '首页') { | ||
第12行: | 第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(- | const targetX = Math.max(-10, Math.min(10, -y / 60)); // 速度减慢 | ||
const targetY = Math.max(- | const targetY = Math.max(-10, Math.min(10, x / 60)); // 速度减慢 | ||
// 使用缓动算法逐步接近目标角度 | // 使用缓动算法逐步接近目标角度 | ||
currentX += (targetX - currentX) * 0. | currentX += (targetX - currentX) * 0.1; | ||
currentY += (targetY - currentY) * 0. | currentY += (targetY - currentY) * 0.1; | ||
// | // 计算颜色深度 | ||
const distance = Math.sqrt(x * x + y * y); | const distance = Math.sqrt(x * x + y * y); | ||
const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2); | const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2); | ||
const | const colorIntensity = Math.max(0, 1 - (distance / maxDistance) * 0.5); | ||
// 应用3D旋转和背景颜色变化 | // 应用3D旋转和背景颜色变化 | ||
rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`; | rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`; | ||
rotatingDiv.style.backgroundColor = ` | rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, ${colorIntensity})`; | ||
}); | }); | ||
第41行: | 第36行: | ||
currentY = 0; | currentY = 0; | ||
rotatingDiv.style.transform = `rotateX(0deg) rotateY(0deg)`; | rotatingDiv.style.transform = `rotateX(0deg) rotateY(0deg)`; | ||
rotatingDiv.style.backgroundColor = ` | rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, 1)`; | ||
}); | }); | ||
} | } |
2024年10月28日 (一) 22:04的版本
/* 这里的任何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)`; }); }