JQuery.waypoint - direction is undefined

I have a problem using waypoint plugin, so many hints like http://webdesign.tutsplus.com/tutorials/javascript-tutorials/create-a-sticky-navigation-header-using-jquery-waypoints/ .

Here is my code:

<script type="text/javascript">

jQuery(function() {
var nav_container = jQuery("#menu-wrapper");
var nav = jQuery("#menu");
nav_container.waypoint(function(event, direction) {

    jQuery("#fixed").toggleClass('stickyfixed');
    jQuery('#zweitenavigation').toggleClass('invisible');
    alert(direction);
    var new_height  = (direction === "down") ? '92px' : '195px';
    jQuery("#header").animate({'height': new_height}, 300);
},{offset:50}
);
});
</script>

      

The problem is

direction === "down"

      

doesn't evaluate to true or false, it's just undefined. Therefore, the animation only runs once.

Does anyone have an idea where the problem might be found? ToggleClass works fine.

Thanks for your help and best wishes Stephan

+3


source to share


1 answer


Waypoints version 2.0 got rid of the parameter event

. Now only exists direction

. The tutorial you referenced made a pretty big mistake with this new version of Waypoints by not updating their tutorial to match the new handler signature.



+8


source







All Articles