Felice
Felice

Reputation: 581

Waypoint function undefined

I am just starting out with Waypoints in a site I want to create.

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

However the console spits 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="[email protected]" 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 a link to plunker.

Upvotes: 2

Views: 5258

Answers (1)

imakewebthings
imakewebthings

Reputation: 3398

You are requiring Waypoints version 2.0.4 but using it in a way that only works with Waypoints 3.0+. Upgrade to the latest version.

Upvotes: 3

Related Questions