eozzy
eozzy

Reputation: 68650

Reset on Hover (jQuery)

$("#notification").slideDown("slow").delay(2000).slideUp("slow");

.. works, but I want to add a condition so that if #notification is hovered, the timer/delay is stopped until mouseout. Then On mouseout the timer starts and then eventually the element is hidden (unless its not hovered again).

Thanks!

Upvotes: 0

Views: 1276

Answers (2)

Sidharth Panwar
Sidharth Panwar

Reputation: 4654

Try handling the onmouseover (not onmousehover) event.

Upvotes: 0

Marko
Marko

Reputation: 72222

If I understand you correctly, you wanna be able to stop the delay/animation if you hover the element?

Use clearQueue() for that

$(document).ready(function() {
    if(cookieIsPresent) {
        $("#notification").hover(function() {
            $(this).stop(true, true).clearQueue(); // You might not need to use clearQueue() but test it out
        }, function() {
            $(this).delay(2000).slideUp("slow");
        }).slideDown("slow").delay(2000).slideUp("slow");
    }
});

Upvotes: 2

Related Questions