Created
October 20, 2014 15:52
-
-
Save k7y6t5/7f52be1698ddf346e9d8 to your computer and use it in GitHub Desktop.
Fixed Bar
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
.fix-me.is-fixed { | |
position: fixed; | |
top: 0; | |
z-index: 10; | |
} |
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
/*----------------------- | |
@FIXED NAV | |
------------------------*/ | |
ww.fixed_nav = (function(){ | |
return { | |
init: function() { | |
var $win = $(window), | |
$body = $("body"), | |
$el = $(".fix-me"), | |
eloffset = $el.offset().top; | |
if ($el.length) { | |
$win.scroll(function() { | |
if (eloffset < $win.scrollTop()) { | |
$el.addClass("is-fixed").css({"width":$(".page").outerWidth()}); | |
$body.css({"padding-top":$el.outerHeight()}); | |
} else { | |
$el.removeClass("is-fixed").css({"width":"auto"}); | |
$body.css({"padding-top":"0"}); | |
} | |
}); | |
} | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment