The editors' meeting has been canceled for technical reasons.

MediaWiki:Common.js:修订间差异

来自NeuroWiki
跳转到导航 跳转到搜索
无编辑摘要
标签已被回退
无编辑摘要
标签已被回退
第13行: 第13行:
const y = event.clientY - rect.top - rect.height / 2;
const y = event.clientY - rect.top - rect.height / 2;
// 计算目标角度并限制在±10度,速度减慢3倍
// 计算目标角度并限制在±8度
const targetX = Math.max(-10, Math.min(10, -y / 60)); // 速度减慢
const targetX = Math.max(-8, Math.min(8, -y / 30));
const targetY = Math.max(-10, Math.min(10, x / 60)); // 速度减慢
const targetY = Math.max(-8, Math.min(8, x / 30));
// 使用缓动算法逐步接近目标角度
// 使用缓动算法逐步接近目标角度
currentX += (targetX - currentX) * 0.1;
currentX += (targetX - currentX) * 0.05; // 速度减慢
currentY += (targetY - currentY) * 0.1;
currentY += (targetY - currentY) * 0.05; // 速度减慢
// 计算颜色深度
// 计算颜色变化
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 colorIntensity = Math.max(0, 1 - (distance / maxDistance) * 0.5);
const colorRatio = Math.min(1, distance / maxDistance);
const r = Math.floor(52 + (153 - 52) * colorRatio);
const g = Math.floor(152 + (153 - 152) * colorRatio);
const b = Math.floor(219 + (153 - 219) * colorRatio);
// 应用3D旋转和背景颜色变化
// 应用3D旋转和背景颜色变化
rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`;
rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`;
rotatingDiv.style.backgroundColor = `rgba(52, 152, 219, ${colorIntensity})`;
rotatingDiv.style.backgroundColor = `rgb(${r}, ${g}, ${b})`;
// 让文本颜色也逐渐变为灰色
rotatingDiv.style.color = `rgb(${255 - (255 - 153) * colorRatio}, ${255 - (255 - 153) * colorRatio}, ${255 - (255 - 153) * colorRatio})`;
});
});
第36行: 第42行:
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)`;
rotatingDiv.style.backgroundColor = `#3498db`;
rotatingDiv.style.color = `white`;
});
});
}
}

2024年10月28日 (一) 21:53的版本

/* 这里的任何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;
	
		// 计算目标角度并限制在±8度
		const targetX = Math.max(-8, Math.min(8, -y / 30));
		const targetY = Math.max(-8, Math.min(8, x / 30));
	
		// 使用缓动算法逐步接近目标角度
		currentX += (targetX - currentX) * 0.05; // 速度减慢
		currentY += (targetY - currentY) * 0.05; // 速度减慢
	
		// 计算颜色变化
		const distance = Math.sqrt(x * x + y * y);
		const maxDistance = Math.sqrt((rect.width / 2) ** 2 + (rect.height / 2) ** 2);
		const colorRatio = Math.min(1, distance / maxDistance);
		const r = Math.floor(52 + (153 - 52) * colorRatio);
		const g = Math.floor(152 + (153 - 152) * colorRatio);
		const b = Math.floor(219 + (153 - 219) * colorRatio);
	
		// 应用3D旋转和背景颜色变化
		rotatingDiv.style.transform = `rotateX(${currentX}deg) rotateY(${currentY}deg)`;
		rotatingDiv.style.backgroundColor = `rgb(${r}, ${g}, ${b})`;
	
		// 让文本颜色也逐渐变为灰色
		rotatingDiv.style.color = `rgb(${255 - (255 - 153) * colorRatio}, ${255 - (255 - 153) * colorRatio}, ${255 - (255 - 153) * colorRatio})`;
	});
	
	rotatingDiv.addEventListener('mouseleave', () => {
		// 鼠标离开时恢复初始状态
		currentX = 0;
		currentY = 0;
		rotatingDiv.style.transform = `rotateX(0deg) rotateY(0deg)`;
		rotatingDiv.style.backgroundColor = `#3498db`;
		rotatingDiv.style.color = `white`;
	});
}