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

This commit is contained in:
Robert Richter 2020-04-29 11:31:01 +02:00
parent a9a85843b0
commit 6d6e802fa8
2 changed files with 14 additions and 12 deletions

View File

@ -165,6 +165,12 @@ audio {
} }
} }
/*** Texte des Bildschirmschoners dynamisch bewegen lassen ***/
.clock_y {
position:fixed;
}
/*** Texte des Bildschirmschoners dynamisch bewegen lassen /*** Texte des Bildschirmschoners dynamisch bewegen lassen
.clock_x { .clock_x {

View File

@ -472,37 +472,33 @@ function set_clock() {
// Uhrzeit jede Sekunden anpassen // Uhrzeit jede Sekunden anpassen
setInterval(set_clock, 1000); setInterval(set_clock, 1000);
// Uhrzeit verschieben
$(document).ready(function(){ $(document).ready(function(){
animateDiv(); setTimeout(function(){ animateDiv(); },5000);
}); });
function makeNewPosition(){ function makeNewPosition(){
// Get viewport dimensions
// Get viewport dimensions (remove the dimension of the div) var h = $('.fullheight').height() - $('.clock_y').height();
var h = $('.fullheight').height();// - 50; var w = $('.fullheight').width() - $('.clock_y').width();
var w = $('.fullheight').width();// - 50;
var nh = Math.floor(Math.random() * h); var nh = Math.floor(Math.random() * h);
var nw = Math.floor(Math.random() * w); var nw = Math.floor(Math.random() * w);
return [nh,nw]; return [nh,nw];
};
}
function animateDiv(){ function animateDiv(){
var newq = makeNewPosition(); var newq = makeNewPosition();
var oldq = $('.clock_x').offset(); var oldq = $('.clock_y').offset();
var speed = calcSpeed([oldq.top, oldq.left], newq); var speed = calcSpeed([oldq.top, oldq.left], newq);
$('.clock_x').animate({ top: newq[0], left: newq[1] }, speed, function(){ $('.clock_y').animate({ top: newq[0], left: newq[1] }, speed, function(){
animateDiv(); animateDiv();
}); });
}; };
function calcSpeed(prev, next) { function calcSpeed(prev, next) {
var x = Math.abs(prev[1] - next[1]); var x = Math.abs(prev[1] - next[1]);
var y = Math.abs(prev[0] - next[0]); var y = Math.abs(prev[0] - next[0]);