Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(function( $ ){
- // Add 'shrink' class to site header on scrolling
- $( document ).on('scroll', function(){
- if ( $(window).width() > 800 ) {
- if ( $( document ).scrollTop() > 0 ){
- $( '.site-header' ).addClass( 'shrink' );
- } else {
- $( '.site-header' ).removeClass( 'shrink' );
- }
- }
- });
- // Function to automatically add a top margin to the visible element below .site-header
- function addTopMargin() {
- var header_height = $( ".site-header" ).outerHeight();
- $( ".nav-primary" ).css( "margin-top", header_height + "px" );
- }
- // http://stackoverflow.com/a/1974797/778809
- // Bind to the resize event of the window object
- $(window).on("resize", function () {
- if ( $(window).width() > 800 ) {
- addTopMargin();
- // Invoke the resize event immediately
- }
- }).resize();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement