MediaWiki:Common.js:修订间差异
来自Fuckrooms Wiki
无编辑摘要 |
无编辑摘要 |
||
| 第29行: | 第29行: | ||
const leaf = document.createElement('div'); | const leaf = document.createElement('div'); | ||
leaf.className = 'leaf'; | leaf.className = 'leaf'; | ||
leaf.innerHTML = '🍃'; | leaf.innerHTML = '🍃'; | ||
leaf.style.cssText = ` | leaf.style.cssText = ` | ||
left: ${Math.random() * 100}%; | left: ${Math.random() * 100}%; | ||
| 第45行: | 第45行: | ||
if(leaves.length < 50) { | if(leaves.length < 50) { | ||
createLeaf(); | createLeaf(); | ||
if(Math.random() > 0.8) createLeaf(); | if(Math.random() > 0.8) createLeaf(); | ||
} | } | ||
}, 800); | }, 800); | ||
2025年4月14日 (一) 10:36的版本
(function(){
window.leaves = window.leaves || [];
if(!document.getElementById('leafStyle')){
const style = document.createElement('style');
style.id = 'leafStyle';
style.textContent = `
@keyframes leafFall {
0%{ transform: translate(-20vw, -50px) rotate(0deg) }
100%{ transform: translate(20vw, 120vh) rotate(1080deg) }
}
.leaf {
position: fixed;
z-index: 99999;
pointer-events: none;
font-size: 24px;
opacity: 0.8;
text-shadow: 1px 1px 2px #333;
}
`;
document.head.appendChild(style);
}
function createLeaf(){
const leaf = document.createElement('div');
leaf.className = 'leaf';
leaf.innerHTML = '🍃';
leaf.style.cssText = `
left: ${Math.random() * 100}%;
color: ${['#8BC34A','#4CAF50','#388E3C'][Math.floor(Math.random()*3)]};
animation: leafFall ${8 + Math.random()*12}s cubic-bezier(0.4,0,0.6,1) infinite;
filter: hue-rotate(${Math.random()*60}deg);
`;
document.body.appendChild(leaf);
leaves.push(leaf);
}
function startFall(){
setInterval(() => {
if(leaves.length < 50) {
createLeaf();
if(Math.random() > 0.8) createLeaf();
}
}, 800);
setInterval(() => {
leaves = leaves.filter(leaf => {
if(leaf.getBoundingClientRect().top > window.innerHeight*1.2){
leaf.remove();
return false;
}
return true;
});
}, 5000);
}
document.addEventListener('visibilitychange', () => {
if(!document.hidden) startFall();
});
startFall();
})();