MediaWiki:Common.js:修订间差异
来自Fuckrooms Wiki
无编辑摘要 |
无编辑摘要 |
||
第2行: | 第2行: | ||
(function(){ | (function(){ | ||
window. | window.leaves = window.leaves || []; | ||
if(!document.getElementById('leafStyle')){ | |||
const | const style = document.createElement('style'); | ||
style.id = 'leafStyle'; | |||
style.textContent = ` | |||
@keyframes leafFall { | |||
0%{ transform: translate(-20vw, -50px) rotate(0deg) } | |||
pointer-events:none; | 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); | |||
} | } | ||
if( | 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', () => { | document.addEventListener('visibilitychange', () => { | ||
if(!document.hidden | if(!document.hidden) startFall(); | ||
}); | }); | ||
startFall(); | |||
})(); | })(); |
2025年4月14日 (一) 10:35的版本
(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(); })();