Authored by 李靖

改成根据为你优选位置判断回到顶部按钮

... ... @@ -16,7 +16,8 @@ class NewHome extends Page {
$codeSet: $('.code-set'),
$resYas: $('.res-c').find('a'),
$trendCode: $('.trend-code'),
$floatTop: $('.float-top')
$floatTop: $('.float-top'),
$recommendC: $('#new-recommend-c')
};
this.init();
... ... @@ -33,13 +34,17 @@ class NewHome extends Page {
}
backToTop() {
$(document).scroll(() => {
if (($(document).scrollTop() >= 120)) {
this.selector.$floatTop.addClass('hover');
} else {
this.selector.$floatTop.removeClass('hover');
}
});
if (this.selector.$recommendC.length > 0) {
$(document).scroll(() => {
let recommendTop = this.selector.$recommendC.offset().top - $(document).scrollTop();
if (recommendTop <= 400) {
this.selector.$floatTop.addClass('hover');
} else {
this.selector.$floatTop.removeClass('hover');
}
});
}
}
autoScroll() {
... ...
... ... @@ -43,7 +43,7 @@ class NewRecommend extends Page {
this.selector.$goodsContainer.append($goodsData);
lazyLoad($goodsData.find('img.lazy'));
} else {
this.selector.$recommendC.hide();
this.selector.$recommendC.remove();
}
}
}).catch(error => {
... ...