42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
(function($) {
|
|
// Nur ausführen, wenn die Body-Klasse vorhanden ist
|
|
if (!$('body').hasClass('festive-christmas')) {
|
|
return;
|
|
}
|
|
|
|
const pluginUrl = fsp_vars.plugin_url;
|
|
|
|
function createSanta() {
|
|
const $santa = $('<img>').attr('src', pluginUrl + 'assets/img/santa-claus.png').css({
|
|
position: 'fixed',
|
|
width: '380px', // Größer gemacht
|
|
bottom: '-350px', // Startet weiter außerhalb des Bildschirms
|
|
right: '-350px', // Startet weiter außerhalb des Bildschirms
|
|
zIndex: 9999,
|
|
pointerEvents: 'none',
|
|
transform: 'rotate(-15deg)' // Leichte Drehung für den Flugeffekt
|
|
});
|
|
|
|
$('body').append($santa);
|
|
|
|
// Animation von rechts nach links über den gesamten Bildschirm
|
|
$santa.animate({
|
|
bottom: window.innerHeight * 0.6, // Fliegt in der oberen Bildschirmhälfte
|
|
right: window.innerWidth + 350, // Fliegt komplett aus dem Bild links raus
|
|
opacity: 0.4 // Wird am Ende fast durchsichtig
|
|
}, {
|
|
duration: 18000, // 18 Sekunden Flugdauer für die große Strecke
|
|
easing: 'linear', // Gleichmäßige Geschwindigkeit
|
|
complete: function() {
|
|
$(this).remove(); // Entfernt das Bild nach der Animation
|
|
}
|
|
});
|
|
}
|
|
|
|
// Ersten Santa nach 5 Sekunden starten
|
|
setTimeout(createSanta, 8000);
|
|
|
|
// Alle 25 Sekunden einen neuen Santa starten
|
|
setInterval(createSanta, 25000);
|
|
|
|
})(jQuery); |