handler option

Default

A no-op function, function() {}.

Possible Values

Any function.

The handler option is the whole point of Waypoints. This is the function that executes when a waypoint is crossed. This function is passed one parameter, direction. If you are scrolling down and cross the waypoint, direction will equal 'down'. If you are scrolling up, it will equal 'up'.

Scroll down to view examples.

var waypoint = new Waypoint({
  element: document.getElementById('handler-example'),
  handler: function(direction) {
    notify('Handler triggered in ' + direction + ' direction')
  },
  offset: 'bottom-in-view'
})

If you're using a horizontal waypoint, the direction parameter is set to either 'right' or 'left'.

var waypoint = new Waypoint({
  element: document.getElementById('handler-example'),
  handler: function(direction) {
    notify('Handler triggered in ' + direction + ' direction')
  },
  context: document.getElementById('overflow-scroll'),
  horizontal: true
})

Horizontal