Revisions
- June 5, 2012 @ 13:52:12 [Current Revision] by PeterLugg
- June 5, 2012 @ 13:57:16 [Autosave] by PeterLugg
- June 5, 2012 @ 13:50:15 by PeterLugg
- June 5, 2012 @ 13:49:12 by PeterLugg
Revision Differences
June 5, 2012 @ 13:49:12 | Current Revision | ||
---|---|---|---|
Content | |||
Deleted: | Added: This has been used in the trial sfor the BlackBocks Nylex website. | ||
Added: Originally taken from <a href="http:// pastebin.com/CCj4L6EL" target="_blank">this pastebin</a>. | |||
Added: This is an untried piece of code, but still interesting: <a href="http:// bforrest.com/ blog/2012/04/ 18/fixed-navigation-bar-with- twitter-bootstrap/" target="_blank">Fixed Navigation Bar With Twitter Bootstrap</a> | |||
Unchanged: [html] | Unchanged: [html] | ||
Unchanged: <script> </pre> | Unchanged: <script> </pre> | ||
Unchanged: $(window).load(function() { | Unchanged: $(window).load(function() { | ||
Unchanged: // fix sub nav on scroll | Unchanged: // fix sub nav on scroll | ||
Unchanged: var $win = $(window) | Unchanged: var $win = $(window) | ||
Unchanged: , $nav = $('.navbar') | Unchanged: , $nav = $('.navbar') | ||
Unchanged: , $nC = $('#navCont') | Unchanged: , $nC = $('#navCont') | ||
Unchanged: , navTop = $('.navbar').length && $('.navbar').offset().top + 20 | Unchanged: , navTop = $('.navbar').length && $('.navbar').offset().top + 20 | ||
Unchanged: , isFixed = 0 | Unchanged: , isFixed = 0 | ||
Unchanged: $nav.addClass( 'auto-size'); | Unchanged: $nav.addClass( 'auto-size'); | ||
Unchanged: processScroll() | Unchanged: processScroll() | ||
Unchanged: $nC.addClass( 'auto-size') | Unchanged: $nC.addClass( 'auto-size') | ||
Unchanged: $win.on('scroll', processScroll) | Unchanged: $win.on('scroll', processScroll) | ||
Unchanged: function processScroll() { | Unchanged: function processScroll() { | ||
Unchanged: var i, scrollTop = $win.scrollTop() | Unchanged: var i, scrollTop = $win.scrollTop() | ||
Unchanged: if (scrollTop >= navTop && !isFixed) { | Unchanged: if (scrollTop >= navTop && !isFixed) { | ||
Unchanged: isFixed = 1 | Unchanged: isFixed = 1 | ||
Unchanged: $nC.removeClass( 'auto-size') | Unchanged: $nC.removeClass( 'auto-size') | ||
Unchanged: $nav.addClass( 'navbar-fixed-top'); | Unchanged: $nav.addClass( 'navbar-fixed-top'); | ||
Unchanged: } else if (scrollTop <= navTop && isFixed) { | Unchanged: } else if (scrollTop <= navTop && isFixed) { | ||
Unchanged: isFixed = 0 | Unchanged: isFixed = 0 | ||
Unchanged: $nC.addClass( 'auto-size') | Unchanged: $nC.addClass( 'auto-size') | ||
Unchanged: $nav.removeClass( 'navbar-fixed-top'); | Unchanged: $nav.removeClass( 'navbar-fixed-top'); | ||
Unchanged: } | Unchanged: } | ||
Unchanged: } | Unchanged: } | ||
Unchanged: }); | Unchanged: }); | ||
Unchanged: <!-- Put this in your stylesheet --> | Unchanged: <!-- Put this in your stylesheet --> | ||
Unchanged: .auto-size { width: auto; } | Unchanged: .auto-size { width: auto; } | ||
Unchanged: <pre> | Unchanged: <pre> | ||
Unchanged: </script> | Unchanged: </script> | ||
Unchanged: [/html] | Unchanged: [/html] | ||
Deleted: | |||
Deleted: |
Note: Spaces may be added to comparison text to allow better line wrapping.
No comments yet.