mistenkt
mistenkt

Reputation: 2392

jQuery Waypoints only triggers when element hits top of window

The title basically says it. It does not matter what I put in the offset param, it only fires when the element hits the top of the window.

 $('.waypoint').waypoint({
        handler: function(direction) {
            console.log('hit');
        }
    }, {offset: '100%'});

I have also tried setting context manually, but the results are the same.

Upvotes: 3

Views: 1596

Answers (1)

Luis González
Luis González

Reputation: 3559

Try putting the offset as other key of the same JSON which contains handler

$('.waypoint').waypoint({
    handler: function(direction) {
        console.log('hit');
    },
    offset: '100%'});

I have seen this other way in the official documentation:

 $('.waypoint').waypoint(function(direction) {
  console.log('hit');
 }, {
   offset: '100%'
 })

Upvotes: 2

Related Questions