Guest User

Untitled

a guest
May 7th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($)
  2. {  
  3.     "use strict";
  4.  
  5.     $(document).ready(function()
  6.     {  
  7.         // set sidebar main menu option
  8.         avia_sidebar_menu();
  9.     });
  10.    
  11.    
  12.     function avia_sidebar_menu()
  13.     {
  14.         var win             = $(window),
  15.             main            = $('#main'),
  16.             sb_header       = $('.html_header_sidebar #header_main'),
  17.             sidebar         = $('.html_header_sidebar #header.av_conditional_sticky');
  18.            
  19.         if(!sb_header.length) return;
  20.         // main.css({"min-height":sb_header.outerHeight()});
  21.        
  22.    
  23.            
  24.         if(!sidebar.length) return;
  25.  
  26.         console.log("1")
  27.        
  28.         var innerSidebar    = $('#header_main'),
  29.             wrap            = $('#wrap_all'),
  30.             fixed_frame     = $('.av-frame-top').height() * 2 || 0,
  31.             subtract        = parseInt($('html').css('margin-top'), 10),
  32.             calc_values     = function()
  33.             {  
  34.                 console.log(fixed_frame)
  35.                 console.log(innerSidebar.outerHeight())
  36.                 console.log(win.height())
  37.                 if(innerSidebar.outerHeight() + fixed_frame < win.height())
  38.                 {  
  39.                     console.log("2")
  40.                     sidebar.addClass('av_always_sticky');
  41.                 }
  42.                 else
  43.                 {
  44.                     console.log("3")
  45.                     sidebar.removeClass('av_always_sticky');
  46.                 }
  47.                
  48.                 wrap.css({'min-height': win.height() - subtract});
  49.             };
  50.        
  51.         calc_values();
  52.         win.on("debouncedresize av-height-change",  calc_values);
  53.     }
  54.    
  55.    
  56.  
  57.  
  58. })(jQuery);
  59.  
  60.  
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment