jeudi 14 juillet 2016

How to set a 'easeOutBounce' for .scrollTop in jQuery?


I need to set a easeOutBounce for a webpage back-to-top button .

I have below code for .scrollTop but unable to add

{
    duration: 2000,
    easing: "easeOutBounce"
}

Existing .js:

$(document).ready(function() {
    // Show or hide the sticky footer button
    $(window).scroll(function() {
    if ($(this).scrollTop() > 500) {
        $('.back-to-top').fadeIn(200);
    } else {
        $('.back-to-top').fadeOut(200);
    }
});

// Animate the scroll to top
$('.back-to-top').click(function(event) {
    event.preventDefault();

    $('html, body').animate({scrollTop: 0}, 300);
    });
});

Aucun commentaire:

Enregistrer un commentaire