当元素底部向上滚动到视图时,使航点点火

时间:2014-08-27 14:24:29

标签: jquery offset jquery-waypoints

如果我想在元素滚动向上进入视图时立即触发航点,该怎么办?向下滚动时,我发生了一个航点。这很好。但是,一旦元素向上滚动到视图(屏幕底部的元素顶部),我希望另一个航点被触发。

$(".picture").waypoint(function(direction){
            var $this = $(this);
            if (direction === "down") {
                setTimeout(function()
                    {
                        $this.children('.cutline_background').animate({"left":"0px"},2500, function(){});
                        $this.children('.text').animate({"left":"40px"},2500, function(){});
                    }, 3000);

            } 
    }, {offset: 0 });
    $(".picture").waypoint(function(direction){
            var $this = $(this);
            if (direction === "up") {
                $this.children('.cutline_background').css("left", "-20%");  
                $this.children('.text').css("left", "-20%");

            } 
    }, {offset: '90%' }); //this doesn't seem to be working

1 个答案:

答案 0 :(得分:0)

Waypoints有一个偏移别名:bottom-in-view

$('.thing').waypoint(function(direction) {
  // do things
}, {
  offset: 'bottom-in-view'
})