Waypoint function undefined

I am just getting started with Waypoints on a site I want to create.

For testing purposes, I created a page with 4 colored divs. I want to check if the waypoints function fires when I view the second div.

However, the console spits out an error: Uncaught ReferenceError: Waypoint is not defined

HTML:

    <!DOCTYPE html>
<html>

  <head>
    <script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script data-require="waypoints@2.0.4" data-semver="2.0.4" src="//cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.4/waypoints.min.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body>
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>
    <div id="four"></div>
  </body>

</html>

      

CSS

#one{
  background-color:red;
 // width:100%;
  height:400px;
}

#two{
  background-color:blue;
  float:clear;
  height:400px;
}

#three{
  background-color:green;
  height:400px;
}

#four{
  background-color:yellow;
  height:400px;
}

      

Jquery / WAYPOINTS:

var waypoint = new Waypoint({
  element: document.getElementById('#two'),
  handler: function(direction) {
    alert('I am 20px from the top of the window');
  },
});

      

Here is the link to the plunker.

+2


source to share


1 answer


You need Waypoints version 2.0.4, but use it in a way that only works with Waypoints 3.0+. Please update to the latest version.



+3


source







All Articles