我想使用jQuery Waypoint函数来切换函数,如何结合这些代码来实现呢? (我也会对替代解决方案感到满意)。

我想结合一下.....

$('#pageborder').waypoint(function(direction) {
  //do something here
}, { offset: 'bottom-in-view' });


有了这个......

.toggle(function(){
  $('.play', this).removeClass('pausing');
  $('.play', this).addClass('playing');
}, function(){
  $('.play', this).addClass('pausing');
  $('.play', this).removeClass('playing');
});


最终结果应该是到达航路点时切换功能。

有关JQuery Waypoint插件的更多信息,请参见:http://imakewebthings.com/jquery-waypoints/#doc-waypoint

最佳答案

这是在到达航点时使用航点插件执行某事的示例。在我的示例中,我根据用户是向上还是向下滚动来显示和隐藏某些内容:

演示:http://jsfiddle.net/lucuma/pTjta/

$(document).ready(function () {
    $('.container div:eq(1)').waypoint(function (direction) {
        if (direction == 'down') $('.toggleme').show();
        else {
            $('.toggleme').hide();
        }
    }, {
        offset: $.waypoints('viewportHeight') / 2

    });
});

关于javascript - 如何使用jQuery Waypoint切换功能,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15853668/

10-10 03:14