Authored by biao

update for make the recommend-for-you be sent after scroll. code review by LZF

... ... @@ -10,9 +10,20 @@ var Swiper = require('yoho.iswiper'),
var recommendSwiper,
$recommendForYou = $('.recommend-for-you'),
preferenceUrl = $('#preferenceUrl').val();
preferenceUrl = $('#preferenceUrl').val(),
winH = $(window).height(),
end = false,
requesting = false;
if (preferenceUrl) {
function request() {
if (requesting || end) {
return;
}
requesting = true;
if (preferenceUrl) {
$.get(preferenceUrl).then(function(html) {
if (html.length < 5) {
$recommendForYou.css('display', 'none');
... ... @@ -29,9 +40,17 @@ if (preferenceUrl) {
}
}
window.rePosFooter();
requesting = false;
end = true;
}).fail(function() {
$recommendForYou.hide();
});
}
}
$(window).scroll(function() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) {
request();
}
});
... ...