javascript - Waypoints: do something if offset is less than something -
i want toggle navbar class if body offset less -20px using waypoints plugin.
the code below doesn't work because offset values undefined.
is there way retrieve body offset value using waypoints?
$("body").waypoint(function() {     if (offset > -20px) {       $(".navbar-toggle").on('click', function() {           $(".navbar").toggleclass("navbar-default navbar-inverse");       });     } });      
.offset() returns object containing properties top , left.  
$("body").waypoint(function() {     var offsettop = $('body').offset().top; // top offset     var offsetleft = $('body').offset().left; // left offset     if (offsettop > -20) { // or offsetleft > -20 out `px`       $(".navbar-toggle").on('click', function() {           $(".navbar").toggleclass("navbar-default navbar-inverse");       });     } });      
Comments
Post a Comment