group.last()

Parameters

None.

Returns

A Waypoint instance.

This method returns the last waypoint in the group. "Last" is determined by the trigger point of the waypoints in the group, where "last" is the waypoint with the bottom-most (or right-most for horizontal waypoints) trigger point.

In the example below, we'll set up two groups of waypoints, even and odds. Both groups of waypoints do the same thing: If the waypoint hit is the last waypoint in the group, it will produce a different notification from the others.

var evens = document.getElementsByClassName('group-even')
var odds = document.getElementsByClassName('group-odd')

function handler(direction) {
  if (this === this.group.last()) {
    notify('Last ' + this.group.name + ' hit')
  }
  else {
    notify('Some other ' + this.group.name + ' hit')
  }
}

evens.forEach(function(element) {
  new Waypoint({
    element: element,
    handler: handler,
    offset: 'bottom-in-view',
    group: 'even'
  })
})

odds.forEach(function(element) {
  new Waypoint({
    element: element,
    handler: handler
    offset: 'bottom-in-view',
    group: 'odd'
  })
})

Odd
Even
Odd
Even
Odd
Even
Odd
Even
Odd
Even