EduardET

Untitled

May 16th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. ( function( $ ) {
  3.     $( document ).ready( function() {
  4.         if ( $( "body" ).hasClass( 'page-id-39' ) ) {
  5.             var mainHeader = $( '#main-header' ),
  6.                 lastScrollTop = 0,
  7.                 distance = $( '.show-logo' ).offset().top;
  8.  
  9.  
  10.             $( window ).scroll( function( event ) {
  11.                 var st = $( this ).scrollTop(),
  12.                     wpbarHeight = $( '#wpadminbar' ).height(),
  13.                     mainHeaderHeight = mainHeader.height(),
  14.                     section = $( '.show-logo' );
  15.  
  16.                 if ( st > lastScrollTop ) {
  17.                     if ( mainHeader.hasClass( 'et-fixed-header' ) ) {
  18.                         mainHeader.addClass( 'wpc-header' );
  19.                     }
  20.                 } else {
  21.                     if ( mainHeader.hasClass( 'wpc-header' ) ) {
  22.                         mainHeader.removeClass( 'wpc-header' );
  23.                     }
  24.                 }
  25.                 lastScrollTop = st;
  26.  
  27.                 if ( st >= distance - ( wpbarHeight + mainHeaderHeight ) ) {
  28.                     if ( mainHeader.hasClass( 'wpc-header' ) ) {
  29.                         mainHeader.removeClass( 'wpc-header' );
  30.                     }
  31.                 } else {
  32.                     if ( !mainHeader.hasClass( 'wpc-header' ) ) {
  33.                         mainHeader.addClass( 'wpc-header' );
  34.                     }
  35.                 }
  36.             } )
  37.         }
  38.     } );
  39. } )( jQuery );
  40. </script>
Advertisement
Add Comment
Please, Sign In to add comment