使用jquery Waypoints.js“停放”一个div

时间:2014-01-18 03:31:57

标签: jquery jquery-waypoints

我创建了一个按预期修复的div。然而,稍后在页面上我想让它在滚动到达特定div时变为“停放”。这可以实现吗?

<div class="content">
    <div class="topper"></div>
    <div class="margins">This is .margins
        <div class="container"> This is .container
            <div class="waypoint">.waypoint - gets .stuck</div>
        </div>
    </div>    
    <div class="stophere">How can I make .waypoint park here until I scroll back up?</div>
</div>

JS:

$('.stophere').waypoint(function(direction) {
  $('.waypoint').waypoint('unsticky');
});

我已经创建了一个fiddle,我已经在这里花了好几个小时了。

1 个答案:

答案 0 :(得分:1)

而不是$('.waypoint').waypoint('unsticky');为您的航点项添加一个类。根据需要设置该类以将其放置在您想要的位置。您需要的确切样式取决于您的页面,因此我无法提供更多详细信息。