group.first()

Parameters

None.

Returns

A Waypoint instance.

This method returns the first waypoint in the group. "First" is determined by the trigger point of the waypoints in the group, where "first" is the waypoint with the top-most (or left-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 first 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.first()) {
    notify('First ' + 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