当您到达我的站点的jQuery区域时,我使用div.main-content Waypoint调用一个“返回到顶部”按钮,如下所示:
$('div.page.event div.main-content').waypoint(function() {
$('button.scrollToTop').fadeIn(200);
});但我不知道如何将其反转,这样当您回到header.main-header时,按钮就会消失。我试过这个:
$('div.page.event header.main-header').waypoint(function() {
$('button.scrollToTop').fadeOut(200);
});但这不管用。我肯定这太简单了,我只是没抓住重点。有人能帮忙吗?
发布于 2013-10-23 04:39:07
您可以使用传递给waypoint函数的direction参数。它的值将是“向下”或“向上”,这取决于用户在穿越路径点时滚动的方向:
$('div.page.event div.main-content').waypoint(function(direction) {
if (direction === 'down') {
$('button.scrollToTop').fadeIn(200);
}
else {
$('button.scrollToTop').fadeOut(200);
}
});https://stackoverflow.com/questions/19455634
复制相似问题