Every waypoint belongs to a
Context is a wrapper around a scrollable DOM element (or
window), and there is always only one
Context for any element. Contexts are only created for an element if a Waypoint is created with that element supplied as the context option. Because
Waypoint creation automatically drives
Context creation, you never need to instantiate this class directly. Instead, instances of this class should be retrieved through a waypoint's context property, or by using Waypoint.Context.findByElement.
Context plays a crucial role. It oversees the
resize events for the element it represents and makes the necessary checks for which waypoints to trigger. As part of these duties, it keeps a few internal state properties, namely booleans used for event throttling and previous scroll positions. Besides those properties, let's look at others more useful to Waypoints users.
This property gives you the instance of the adapter wrapped around the DOM element of this context. Most Waypoints users should use the element property to access this element, but
adapter is useful for developers writing Waypoints extensions or scripts that are intended to be used across all the different framework builds of Waypoints.
This property gives you the underlying DOM element (or
window, in the default case) of the context.
waypoints property is an object with two properties,
vertical. Each of those properties are themselves objects containing all the horizontal and vertical waypoints in the context respectively. The keys of those objects are a unique internal id assigned to a waypoint, and the values are the
Waypoint instances themselves. The whole object might look like this at any given time:
Let's look at the
waypoints property on the
window context for this page.