You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue with the detach trigger not unfixing the sticky header when called. I'm calling it from a custom function because I'm calculating the height of submenus so that the header is fixed when the menu fits in the viewport but unfixed when the menu doesn't fit.
The detach trigger is called when the window is resized (and smaller than the height of the menus) but it doesn't unfix the header.
Here's my code:
functionstickyHeader(){varViewportHeight;varHeaderHeight;varMenuHeight;ViewportHeight=$(window).height();HeaderHeight=$(".header").height();MenuHeight=0;// if main menu is active, get height of longest submenuif($("#menu-main-menu").height()!=0){$("#menu-main-menu .sub-menu").each(function(){varHeight=$(this).height();if(Height>MenuHeight){MenuHeight=Height;}});}// else use height of mobile menu"s longest submenuelse{$("#menu-mobile-menu .sub-menu").each(function(){varHeight=$(this).height();if(Height>MenuHeight){MenuHeight=Height;}});}varmenu=HeaderHeight+MenuHeight;// make the menu sticky if fits inside windowif((HeaderHeight+MenuHeight)<ViewportHeight){$(".header").scrollToFixed();}else{$(".header").trigger("detach.ScrollToFixed");}}$(window).on("load",function(){stickyHeader();window.addEventListener("resize",function(){stickyHeader();console.log("resizing");});});
The text was updated successfully, but these errors were encountered:
I was able to solve this by resetting the inline styles on the fixed element after detaching ScrollToFixed. It'd be great if clearing the styles could be part of the native detach function because the inline styles continue to make the element sticky even after detaching the plugin.
Thanks for the great plugin!
I'm having an issue with the detach trigger not unfixing the sticky header when called. I'm calling it from a custom function because I'm calculating the height of submenus so that the header is fixed when the menu fits in the viewport but unfixed when the menu doesn't fit.
The detach trigger is called when the window is resized (and smaller than the height of the menus) but it doesn't unfix the header.
Here's my code:
The text was updated successfully, but these errors were encountered: