Last active
October 13, 2015 15:38
-
-
Save pakMann/4217983 to your computer and use it in GitHub Desktop.
sticky menu on header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $topContent = $("#homepage") | |
| $nav = $(".navbar") | |
| navHeight = $nav.outerHeight(false) | |
| stickyNav = -> | |
| browserHeight = $(window).height() | |
| navTopPos = browserHeight - navHeight | |
| $topContent.css height: navTopPos | |
| scrollTop = $(window).scrollTop() | |
| if scrollTop > navTopPos | |
| $nav.css | |
| position: "fixed" | |
| top: 0 | |
| width: "100%" | |
| else | |
| $nav.removeAttr "style" | |
| stickyNav() | |
| $(window).resize -> | |
| stickyNav() | |
| $(window).scroll -> | |
| stickyNav() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment