我想使用 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/