Search code examples
jqueryjquery-waypoints

How to fire a callback when using jQuery Waypoints Sticky Shortcut?


I want to toggle a class of another element whenever waypoint('sticky') changes the class of the navigation bar. I was trying to fire a callback using the handler option, but it does not work. What could I do?


Solution

  • The callback option for Waypoints is, for some reason, "handler", so you could do it like this:

    $.waypoint('sticky', {
        handler: function(dir) {
            //Do stuff when the user scrolls past this waypoint.
        }
    });