Search code examples
jquerywordpress-themingjquery-waypoints

WordPress/waypoints.js Uncaught TypeError: Illegal invocation


Using WP 4.1, custom js

var waypoints = $('#about').waypoint({
  handler: function(direction) {
    console.log(this.element.id + ' hit')
  }
})

Getting this error in my console

Uncaught TypeError: Illegal invocationjquery.waypoints.min.js?ver=3.0.1:7
(anonymous function)jquery.js?ver=1.11.1:3 m.event.dispatchjquery.js?ver=1.11.1:3 r.handle

Any help is greatly appreciated.


Solution

  • This is a bug in Waypoints, with a fix open that will be merged soon. The error stems from the fact that requestAnimationFrame must be called with window as the context.

    Update: That fix has landed in 3.1.0.