waypoints - GetMeFoodie
Waypoints is the easiest way to trigger a function when you scroll to an element. var waypoint = new Waypoint({ element: document.getElementById('waypoint'), handler: function(direction) {.
Waypoints is the easiest way to trigger a function when you scroll to an element. var waypoint = new Waypoint({ element: document.getElementById('waypoint'), handler: function(direction) {.
The element tells Waypoints which DOM element's position to observe during scroll, and handler is the function that will trigger when the top of that element hits the top of the viewport. Directions You may.
Waypoint Class Waypoints are created by instantiating this class. How you instantiate a waypoint depends on which build you use (jQuery, Zepto, or no-framework dependency.) All builds support.
Understanding the Context
As part of this calculation, Waypoints looks for the element's position on the page. This doesn't return the position as if the element were still staticly positioned, but instead returns the element's current.
Getting Started jQuery/Zepto Debugging Adapters jQuery/Zepto 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.
The default directions handle the most common case for both vertical and horizontal waypoints: You start at the top and wish to add the stuck state when scrolling down and reaching the element (right.
container Default: 'auto'. Newly loaded items are appended to the container. The default value of 'auto' means the container will be the same element as the element option. The element option, in.
Key Insights
Waypoint.destroyAll () Parameters None. Returns undefined. Destroys all Waypoints. This is the same as calling destroy on every waypoint, or calling destroy on every context. Scroll down to view an.
The Waypoints lib directory contains three different builds of the library for different DOM manipulation frameworks: jQuery, Zepto, and no framework. This is accomplished by factoring out all of the code.
This method often comes in handy when writing function offsets, particularly for horizontal waypoints. For example, if your horizontal waypoint has the default context of window, the right-in-view alias works.