我正在使用 jquery waypoints ( http://imakewebthings.com/jquery-waypoints/#docs ) 来检查元素是否是浏览器的视图
我只想在视口中向上或向下滚动时仅显示一次元素......这里是 js
var inview = new Waypoint.Inview({
element: $('#waypoint')[0],
enter: function(direction) {
if (direction === 'down') {
setTimeout(function() {
$('#first').hide('fast');
}, 500); // <-- time in milliseconds
setTimeout(function() {
$('#second').fadeIn("fast");;
}, 500); // <-- time in milliseconds
}
if (direction === 'up') {
setTimeout(function() {
$('#first').hide('fast');
}, 500); // <-- time in milliseconds
setTimeout(function() {
$('#second').fadeIn("fast");;
}, 500); // <-- time in milliseconds
}
}
})
此代码在向下滚动时运行良好,但在向上滚动时不起作用。
我想当检测位置下降时只运行下降功能,当检测位置上升时只运行功能上升