Dateien nach "assets/js" hochladen
This commit is contained in:
42
assets/js/easter-eggs.js
Normal file
42
assets/js/easter-eggs.js
Normal file
@@ -0,0 +1,42 @@
|
||||
(function($) {
|
||||
// Skript nur ausführen, wenn die body-Klasse 'festive-easter' vorhanden ist
|
||||
if (!$('body').hasClass('festive-easter')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Pfad zum Plugin-Verzeichnis wird von PHP übergeben (siehe wp_localize_script)
|
||||
const pluginUrl = fsp_vars.plugin_url;
|
||||
|
||||
const eggImages = [
|
||||
pluginUrl + 'assets/img/easter-egg-1.png',
|
||||
pluginUrl + 'assets/img/easter-egg-2.png',
|
||||
pluginUrl + 'assets/img/easter-egg-3.png',
|
||||
pluginUrl + 'assets/img/easter-egg-4.png',
|
||||
pluginUrl + 'assets/img/easter-egg-5.png',
|
||||
pluginUrl + 'assets/img/easter-egg-6.png',
|
||||
pluginUrl + 'assets/img/easter-egg-7.png',
|
||||
pluginUrl + 'assets/img/easter-egg-8.png',
|
||||
pluginUrl + 'assets/img/easter-egg-9.png'
|
||||
];
|
||||
|
||||
function createEgg() {
|
||||
const randomEgg = eggImages[Math.floor(Math.random() * eggImages.length)];
|
||||
const $egg = $('<img>').attr('src', randomEgg).css({
|
||||
position: 'fixed',
|
||||
width: '60px',
|
||||
left: Math.random() * 100 + '%',
|
||||
top: '-80px',
|
||||
zIndex: 9999,
|
||||
pointerEvents: 'none',
|
||||
transform: 'translateX(-50%)'
|
||||
});
|
||||
|
||||
$('body').append($egg);
|
||||
|
||||
$egg.animate({ top: '110vh' }, 7000, 'linear', function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(createEgg, 900);
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user