currency.js 656 Bytes
var $ = require('jquery');
var page = 1;

function ajaxCurrencyDetail(page) {
    $.ajax({
        type: 'POST',
        url: '/home/ajaxCurrencyDetail',
        dataType: 'html',
        data: {
            page: page
        },
        success: function(data) {
            $('.coin-detail').append(data);
            window.rePosFooter();
        }
    });
}

function scrollHandler() {
    if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
        page++;
        ajaxCurrencyDetail(page);
        return;
    }
}

$(window).scroll(function() {
    window.requestAnimationFrame(scrollHandler);
});

ajaxCurrencyDetail(page);