diff --git a/public/css/waip.css b/public/css/waip.css index 4f82bde..ee751bc 100644 --- a/public/css/waip.css +++ b/public/css/waip.css @@ -165,7 +165,7 @@ audio { } } -/*** Texte des Bildschirmschoners dynamisch bewegen lassen **********/ +/*** Texte des Bildschirmschoners dynamisch bewegen lassen .clock_x { animation: x 1200s linear infinite alternate; @@ -196,3 +196,4 @@ audio { transform: translatex(300%); } } +**********/ \ No newline at end of file diff --git a/public/js/client_waip.js b/public/js/client_waip.js index 39de0fb..f811978 100644 --- a/public/js/client_waip.js +++ b/public/js/client_waip.js @@ -472,6 +472,55 @@ function set_clock() { // Uhrzeit jede Sekunden anpassen 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 ####### */ /* ########################### */