为什么它不能正常工作?我需要创建两个不同的偏移量。向上滚动小,向下滚动最大。这段代码不能很好地工作。
// The same for all waypoints
$('body').delegate('section > article', 'waypoint.reached', function(event, direction) {
var $active = $(this);
if (direction === "up") {
$active = $active.prev();
$('section > article').waypoint({ offset: '10%' });
}
if (!$active.length) $active = $active.end();
if (direction === "down") {
$('section > article').waypoint({ offset: '60%' });
}
$('.link-active').removeClass('link-active');
$('a[href=#'+$active.attr('id')+']').addClass('link-active');
});
// Register each section as a waypoint.
$('section > article#p1').waypoint({ offset: '28%' });
$('section > article').waypoint({ offset: '0' });