Magento – Smooth scroll to top pagination from Ajax extension

javascriptjquerymagento-1.9

How can I implement smooth scroll to top in a ajax extension that does pagination. The extension has the code following

if (block && amshopby_scroll_to_products) {
    $$('body')[0].scrollTo();
}

and I have following code in my theme phtml which does smooth scroll to top functionality. Is it possible to call this functionality from the extension js file mentioned above.If not what is the the solution to implement?

    var windowScroll_t;
    $(window).scroll(function(){

        clearTimeout(windowScroll_t);
        windowScroll_t = setTimeout(function() {

            if ($(this).scrollTop() > 100)
            {
                $('#scroll-to-top').fadeIn();
            }
            else
            {
                $('#scroll-to-top').fadeOut();
            }

        }, 500);

    });

    $('#scroll-to-top').click(function(){
        $("html, body").animate({scrollTop: 0}, 600, "easeOutCubic");
        return false;
    });

Best Answer

You probably use Amasty module, I had the same problem. There is hidden option in amshopby-ajax.js just change false to true. and ajax filtering will scroll to top

var amshopby_toolbar_selector = 'div.toolbar';
var amshopby_scroll_to_products = false;
Related Topic