element: The scrollable HTMLElement of the context object you wish to find.


Context instance, or undefined if no context is associated with the provided element.

Given an element on the page, this method returns the Context instance associated with that element. If the element does not have an associated Context, the method returns undefined.

In this example we can create and destroy a waypoint inside a custom context. Another button shows us the result of calling findByElement. Notice when the waypoint is created (and as a result the Context is created) the method returns that Context. When the waypoint is destroyed (which also destroys the Context since it is empty) the call returns undefined.

var waypoint

$('button.find-create').on('click', function() {
  waypoint = new Waypoint({
    element: document.getElementById('find-by-example'),
    handler: function(direction) {
      notify('Waypoint hit')
    context: document.getElementById('overflow-scroll')

$('button.find-destroy').on('click', function() {

$('button.find-by-element').on('click', function() {
  var element = document.getElementById('overflow-scroll')
  var context = Waypoint.Context.findByElement(element)
  if (typeof context === 'undefined') {
    notify('Context does not exist')
  else if (context instanceof Waypoint.Context) {
    notify('Context found')