Mudanças entre as edições de "MediaWiki:Common.js"
Ir para navegação
Ir para pesquisar
(teste efeito natal) |
(edição teste 02 - natal efeitos.) |
||
| Linha 34: | Linha 34: | ||
}); | }); | ||
| − | |||
mw.loader.using(['jquery'], function () { | mw.loader.using(['jquery'], function () { | ||
| − | const | + | function criarFloco() { |
| − | + | const floco = document.createElement("div"); | |
| + | floco.className = "snowflake"; | ||
| + | floco.textContent = "❄"; | ||
| + | |||
| + | // posição inicial aleatória | ||
| + | floco.style.left = Math.random() * 100 + "vw"; | ||
| − | + | // tamanho aleatório | |
| − | + | floco.style.fontSize = (10 + Math.random() * 12) + "px"; | |
| − | |||
| − | + | // duração da animação | |
| − | floco.style.animationDuration = (6 + Math.random() * 6) + | + | floco.style.animationDuration = (6 + Math.random() * 6) + "s"; |
| − | |||
| − | |||
document.body.appendChild(floco); | document.body.appendChild(floco); | ||
| − | // remover | + | // remover depois |
setTimeout(() => floco.remove(), 12000); | setTimeout(() => floco.remove(), 12000); | ||
} | } | ||
| − | // | + | // cria flocos a cada 300 ms |
| − | setInterval(criarFloco, | + | setInterval(criarFloco, 300); |
| − | |||
}); | }); | ||
| − | // | + | // coloca drift aleatório em cada floco |
| − | document.addEventListener("animationstart", function (e) { | + | document.addEventListener("animationstart", function(e) { |
if (e.target.classList.contains("snowflake")) { | if (e.target.classList.contains("snowflake")) { | ||
| − | const | + | const desloc = (Math.random() * 40 - 20); // -20px a +20px |
| − | e.target.style.setProperty( | + | e.target.style.setProperty("--d", desloc + "px"); |
} | } | ||
}); | }); | ||
Edição das 23h34min de 8 de dezembro de 2025
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
$(function() {
// Cria o botão scroll-to-top button
var $botaoTopo = $('<div id="botaoTopo">⬆️ Topo</div>').css({
display: "none",
position: "fixed",
bottom: "85px", // <-- distância do roda pé (~85px)
right: "20px",
padding: "10px 15px",
background: "#9bbeab",
color: "#000",
"border-radius": "8px",
cursor: "pointer",
"box-shadow": "0 2px 6px rgba(0,0,0,0.3)",
"font-weight": "bold",
"z-index": "9999"
}).appendTo("body");
// Mostrar/esconder com base no scroll
$(window).scroll(function() {
if ($(this).scrollTop() > $(document).height() / 2) {
$botaoTopo.fadeIn();
} else {
$botaoTopo.fadeOut();
}
});
// Ação ao clicar
$botaoTopo.click(function() {
$("html, body").animate({scrollTop: 0}, 500);
return false;
});
});
mw.loader.using(['jquery'], function () {
function criarFloco() {
const floco = document.createElement("div");
floco.className = "snowflake";
floco.textContent = "❄";
// posição inicial aleatória
floco.style.left = Math.random() * 100 + "vw";
// tamanho aleatório
floco.style.fontSize = (10 + Math.random() * 12) + "px";
// duração da animação
floco.style.animationDuration = (6 + Math.random() * 6) + "s";
document.body.appendChild(floco);
// remover depois
setTimeout(() => floco.remove(), 12000);
}
// cria flocos a cada 300 ms
setInterval(criarFloco, 300);
});
// coloca drift aleatório em cada floco
document.addEventListener("animationstart", function(e) {
if (e.target.classList.contains("snowflake")) {
const desloc = (Math.random() * 40 - 20); // -20px a +20px
e.target.style.setProperty("--d", desloc + "px");
}
});