context.destroy()

Parameters

None.

Returns

undefined.

This destroys every waypoint in the context, and consequently unbinds any scroll and resize handlers attached to this context's element.

In this example we have two custom contexts. Clicking the destroy button for each will destroy only those waypoints within that context.

var leftElements = document.getElementsByClassName('left-context-waypoint')
var rightElements = document.getElementsByClassName('right-context-waypoint')

function notifyInnerHTML() {
  notify(this.element.innerHTML + ' hit')
}

leftElements.forEach(function(element) {
  new Waypoint({
    element: element,
    handler: notifyInnerHTML,
    context: document.getElementById('left-context')
  })
})

rightElements.forEach(function(element) {
  new Waypoint({
    element: element,
    handler: notifyInnerHTML,
    context: document.getElementById('right-context')
  })
})

$('button.destroy-left-context').on('click', function() {
  var element = document.getElementById('left-context')
  var context = Waypoint.Context.findByElement(element)
  context.destroy()
})

$('button.destroy-right-context').on('click', function() {
  var element = document.getElementById('right-context')
  var context = Waypoint.Context.findByElement(element)
  context.destroy()
})

Left Waypoint 1
Left Waypoint 2
Left Waypoint 3
Left Waypoint 4
Left Waypoint 5
Left Waypoint 6
Left Waypoint 7
Left Waypoint 8
Left Waypoint 9
Right Waypoint 1
Right Waypoint 2
Right Waypoint 3
Right Waypoint 4
Right Waypoint 5
Right Waypoint 6
Right Waypoint 7
Right Waypoint 8
Right Waypoint 9