Prior to version 3.0, Waypoints was strictly a jQuery plugin. You'll notice most of the examples on this site use code that is compatible with the new no-framework build of Waypoints using class instantiation and generally available DOM querying methods, like this:
If you're using the jQuery or Zepto builds, you can still use the no-framework approaches featured in the documentation, but those builds also provide extensions specific to the framework.
waypoint method is added to
$.fn, restoring the old 2.x syntax. Instead of passing in an
element option, a waypoint is created for each of the matched elements.
You may also pass the handler option as the first argument to
In the example above, the
element option is replaced with the element matched by the selector, and the handler option is provided as the first paramter. Because there are no other required options, the second options argument becomes optional. In this case, all other options would be the defaults.
There is one major difference between using the
$.fn.waypoint method with versions 2.0 and 3.0. In 2.0, the same jQuery object was returned for chaining purposes, as is common among core jQuery methods. In 3.0, an array of
Waypoint instances is returned.
The context option expects its value to be an
With jQuery and Zepto builds, you may also pass a CSS selector string. If you do, Waypoints will find the context element using closest with that selector.