0

Hello guys reading this article i create simple screensaver, but i got one problem, when i let my mouse stop i need to hide one div and show other, but when div shows animation stop, what is my problem, my code

var mousetimeout;
var screensaver_active = false;
var idletime = 5;

var screenSaver = $("#screenSaverForm");
var formDiv = $("#bodyForm");

function show_screensaver() {
    formDiv.fadeOut(100);
    screenSaver.fadeIn(900);
    screensaver_active = true;
}

function stop_screensaver() {
    screenSaver.fadeOut(100);
    formDiv.fadeIn(900);
    screensaver_active = false;
}

$(document).mousemove(function () {
    clearTimeout(mousetimeout);

    if (screensaver_active) {
        stop_screensaver();
    }

    mousetimeout = setTimeout(function () {
        show_screensaver();
    }, 1000 * idletime); // 5 secs          
});

and divs:

<div id="screenSaverForm" style="background-image: url(../../Content/img/screensavers.jpg); position: absolute; width: 100%; height:100%; left:0px; top: 0px; display: none; z-index:9999; display: none;">Example of a DIV element with a background image:</div>

Other div is simple, and if any can help, before show animation i need to reload page, any knows how to do this?

Community
  • 1
  • 1
NoNameR
  • 85
  • 12

1 Answers1

0

You could try adding this line in before stop_screensaver();

.
...
if (screensaver_active) {
    location.reload(); //Refreshes the page
    stop_screensaver();
}
...
.

Or, if you just want to scroll to the top of the page:

.
...
if (screensaver_active) {
    $(window).scrollTop(0); //Scroll to top of page
    stop_screensaver();
}
...
.
Dom Slee
  • 611
  • 1
  • 5
  • 10
  • but what about animation stow when one div is making visible? i dont move my mouse but its stop, what a reason? – NoNameR Jul 20 '15 at 07:56