Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Offset with Waypoint.Inview()

I'm using something like this to capture scroll events on a web page:

var myblock = new Waypoint.Inview({
    element: $('#block')[0],
    entered: function(direction) {
     //do stuff
    },
    exited: function(direction) {
      if(direction === "down") {
       // do other stuff
      }
    }
  });

The problem is that I have a sticky menu with a height of 100px at the top, and that I need Waypoint to trigger when some <div id="block"> touches that menu. Right now, the Waypoint code is triggered when <div id="block"> reaches the top of the viewport, where part of the div is already under the menu.

I tried adding the offset parameter but I don't see any changes

var myblock = new Waypoint.Inview({
    element: $('#block')[0],
    entered: function(direction) {
     //do stuff
    },
    exited: function(direction) {
      if(direction == "down") {
       // do other stuff
      }
    },
    offset: 100 // ADDED, NOTHING CHANGED
  });

What am I doing wrong?

like image 917
RRikesh Avatar asked Mar 16 '23 14:03

RRikesh


1 Answers

You are doing nothing wrong. There is currently no support for offsets with the Inview shortcut. At this time you will have to write it using a couple regular Waypoints.

like image 136
imakewebthings Avatar answered Mar 27 '23 16:03

imakewebthings