Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Nav Bar
- app.directive('stickyNav', ['$window', function($window){
- return {
- restrict: 'A',
- scope: '@',
- link: function(scope, element, attrs){
- var showingStickyNav = false;
- var navHeight = element.height();
- // var navOffset = element.offet().top;
- $(window).bind('scroll', function(){
- var scrollPosition = $(window).scrollTop();
- if(scrollPosition > navHeight && showingStickyNav === false){
- showingStickyNav = true;
- $('main').css({'padding-top': element.height()});
- element.velocity('fadeIn', {duration: 350, begin: function(){
- element.css({'position': 'fixed', 'top': 0, 'z-index': 3});
- }});
- }
- else if (scrollPosition < navHeight && showingStickyNav === true){
- showingStickyNav = false;
- $('main').css({'padding-top': 0});
- element.css({'position': 'relative', 'top': ''});
- }
- });
- }
- }
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement