我使用下面的代码,工作得很好。然而,当我在手机上查看它时,触发器不会运行直到滚动停止,而不是在到达该点时。滚动移动设备时有没有办法报告滚动位置?而不是什么时候停止。
var waypoint = new Waypoint({
element: document.getElementById('trigger-1'),
handler: function(direction) {
console.log(direction);
if(direction == "down"){
$(".sign-up-absolute").css("position","fixed");
$(".sign-up-absolute").css("top","25%");
}
else{
$(".sign-up-absolute").css("position","absolute");
$(".sign-up-absolute").css("top","150px");
}
}
});
var waypoint = new Waypoint({
element: document.getElementById('trigger-2'),
handler: function(direction) {
if(direction == "up"){
$(".sign-up-absolute").css("position","fixed");
$(".sign-up-absolute").css("top","25%");
}
else{
$(".sign-up-absolute").css("position","absolute");
$(".sign-up-absolute").css("top","150px");
}
}
});