currency-detail.page.js
841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var $ = require('yoho-jquery'),
loading = require('../plugin/loading');
var page = 1;
var flag = true;
require('../common');
loading.showLoadingMask();
function ajaxCurrencyDetail(curPage) {
flag = false;
$.ajax({
type: 'post',
url: '/home/ajaxCurrencyDetail',
dataType: 'html',
data: {
page: curPage
},
success: function(data) {
$('.coin-detail').append(data);
flag = true;
}
});
}
function scrollHandler() {
if ($(window).scrollTop() + $(window).height() > $('body').height() - 100 && flag) {
page++;
ajaxCurrencyDetail(page);
return;
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
ajaxCurrencyDetail(page);
$(document).ready(loading.hideLoadingMask);