Search code examples
jquery-waypoints

jQuery Waypoints: is Disable on all waypoints still possible?


I am about to include the jQuery Waypoints plugin (version 3 as the version 2 documentation is no longer available) in a new project. I will need to create 20+ waypoints for analytics events and enable/disable all of them in certain circumstances.

In the previous version of the API, I could simply do

 $.waypoints('disable');

and not worry about maintaining and going over a list of instances. Seems like the v.3 API will require this... am I missing something? Is it still possible to disable/enable all waypoints globally?


Solution

  • UPDATE: As of Waypoints 3.1.0 the enableAll and disableAll methods have been added. The original answer below applied to 3.0.0 and 3.0.1


    An analog to the old $.waypoints('disable') doesn't exist. There isn't a Waypoint.disableAll(). But you probably don't have to maintain your own list of Waypoint instances. You can use the Context's list:

    Context.findByElement(window).waypoints.forEach(function(waypoint) {
      waypoint.disable()
    })
    

    If I see a bunch of people needing back global or Context scoped disable/enable I'd consider adding it back to v3.