update Mi 29. Apr 11:01:01 CEST 2020

This commit is contained in:
Robert Richter 2020-04-29 11:01:01 +02:00
parent dfc8417ac6
commit a9a85843b0
2 changed files with 51 additions and 1 deletions

View File

@ -165,7 +165,7 @@ audio {
} }
} }
/*** Texte des Bildschirmschoners dynamisch bewegen lassen **********/ /*** Texte des Bildschirmschoners dynamisch bewegen lassen
.clock_x { .clock_x {
animation: x 1200s linear infinite alternate; animation: x 1200s linear infinite alternate;
@ -196,3 +196,4 @@ audio {
transform: translatex(300%); transform: translatex(300%);
} }
} }
**********/

View File

@ -472,6 +472,55 @@ function set_clock() {
// Uhrzeit jede Sekunden anpassen // Uhrzeit jede Sekunden anpassen
setInterval(set_clock, 1000); setInterval(set_clock, 1000);
$(document).ready(function(){
animateDiv();
});
function makeNewPosition(){
// Get viewport dimensions (remove the dimension of the div)
var h = $('.fullheight').height();// - 50;
var w = $('.fullheight').width();// - 50;
var nh = Math.floor(Math.random() * h);
var nw = Math.floor(Math.random() * w);
return [nh,nw];
}
function animateDiv(){
var newq = makeNewPosition();
var oldq = $('.clock_x').offset();
var speed = calcSpeed([oldq.top, oldq.left], newq);
$('.clock_x').animate({ top: newq[0], left: newq[1] }, speed, function(){
animateDiv();
});
};
function calcSpeed(prev, next) {
var x = Math.abs(prev[1] - next[1]);
var y = Math.abs(prev[0] - next[0]);
var greatest = x > y ? x : y;
var speedModifier = 0.1;
var speed = Math.ceil(greatest/speedModifier);
return speed;
}
/* ########################### */ /* ########################### */
/* ####### Rückmeldung ####### */ /* ####### Rückmeldung ####### */
/* ########################### */ /* ########################### */