i'm trying add class nav-menu assumes fixed position after amount of scrolling. variations of code work in standard environment. however, aem not playing others. report $(window).scrolltop()
value in console along value navmenupos.top
. no matter try though, cannot "hi" me. scroll event appears not firing. here code:
$(document).ready(function() { var navmenu = $('#nav-menu'); var navmenupos = $('#nav-menu').offset(); console.log("window scroll top is: " + $(window).scrolltop()); console.log("the top of top menu is: " + navmenupos.top); $(window).scroll(function() { console.log("hi"); if ($(window).scrolltop() > navmenupos.top) { navmenu.addclass('fixed-pos-menu'); } else { navmenu.removeclass('fixed-pos-menu'); } }); });
in place of $(window).scroll(function() {});
i've tried $(window).bind('scroll', function() {});
, things like:
navmenu.on("scroll", function(e) { if (this.scrolltop > 147) { navmenu.addclass("fixed-pos-menu"); } else { navmenu.removeclass("fixed-pos-menu"); } });
none of these things triggering scroll event.
the window object appears present can information top. maybe aem doesn't see scrolling part of page?
Comments
Post a Comment