Created
February 5, 2019 19:43
-
-
Save isramv/be466284f8570aa3ffe7839396c90e02 to your computer and use it in GitHub Desktop.
sticky nav in discoverla
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
// Sticky navigation. | |
var navbar = $("#navbar"); | |
var stickyClass = "sticky"; | |
var offsetTop = $('#navbar').offset(); | |
$(window, context).scroll(function() { | |
if ( $(this).scrollTop() > offsetTop.top ) { | |
navbar.addClass(stickyClass); | |
$('#dla-main-content').css('margin-top', navbar.height()); | |
} else if ( $(this).scrollTop() < navbar.height() ) { | |
navbar.removeClass(stickyClass); | |
$('#dla-main-content').css('margin-top', 0); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment