rAthus

JS hack for header autohide on scroll for Jupiter WP theme

Jun 20th, 2016
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** JS hack for header autohide on scroll for Jupiter WP theme - v0.3 - by rAthus **/
  2. jQuery(document).ready(function($)
  3. {
  4.     var headerHeight = $('header').attr('data-height')*1;
  5.     var mouseWheelEvt = (/Firefox/i.test(navigator.userAgent))?'DOMMouseScroll':'mousewheel';
  6.     $(document).bind(mouseWheelEvt,function(e)
  7.     {
  8.         var evt = window.event||e;
  9.             evt = evt.originalEvent?evt.originalEvent:evt;
  10.         var delta = evt.detail?evt.detail*(-40):evt.wheelDelta;
  11.         if (delta>0)
  12.             $('header .mk-header-holder').stop(true).animate({'top':'0px'},100,'linear');
  13.         else
  14.             $('header .mk-header-holder').stop(true).animate({'top':'-'+headerHeight+'px'},100,'linear');
  15.     });
  16.     $(document).on('scroll',function(e)
  17.     {
  18.         if ($(window).scrollTop()*1+$(window).height()*1>$(document).height()*1-10)
  19.             $('header .mk-header-holder').stop(true).animate({'top':'0px'},100,'linear');
  20.     });
  21. });
Add Comment
Please, Sign In to add comment