javascript - 如何使用 jquery waypoint 切换功能

标签 javascript jquery jquery-waypoints

我想使用 jQuery 路径点函数切换函数,如何组合这些代码片段来实现这一点? (我也会对替代解决方案感到满意)。

我想结合这个......

$('#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/

相关文章:

javascript - Foundation 6 : How to set . is-open-right translateX value with JavaScript

javascript - 将 JQUERY 函数转换为原生 JavaScript

来自 Greasemonkey 的 jQuery 路径点

javascript - 修复 Jquery Waypoint

javascript - 使用 ON 的 Jquery 航点

javascript - 如何在回调中访问正确的“this”?

javascript - 将第一列的数字乘以第一行的数字的动态表

javascript - 在 JavaScript 中调用另一个函数中的函数的问题

javascript - 如何打开 jquery Jstree 中的所有节点?

jquery - 带有 Bootstrap 类的固定标题 html 表