1/* 2 Title: Hide header on scroll down, show on scroll up 3 Author: Marius Craciunoiu 4 URL: https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c 5 6 Edited by: MNKY (http://themeforest.net/user/MNKY) 7*/ 8 9(function($) { 10'use strict;' 11 12 var didScroll, 13 lastScrollTop = 0, 14 delta = 5, 15 wrapper = $('#header-wrapper'), 16 headerHeight = $('#site-header').height(), 17 headerOffset = $('#site-header').offset().top, 18 headerOut = headerHeight + headerOffset; 19 20 $(window).scroll(function(event){ 21 var scrolled = $(this).scrollTop(); 22 23 if (scrolled > headerOut) { 24 wrapper.addClass('header-sticky'); 25 } else if ( scrolled < headerOffset || scrolled == headerOffset) { 26 wrapper.removeClass('header-sticky'); 27 wrapper.css('top', ''); 28 } 29 30 didScroll = true; 31 }); 32 33 interval(function() { 34 if (didScroll) { 35 hasScrolled(); 36 didScroll = false; 37 } 38 }, 250); 39 40 function interval(func, wait, times){ 41 var interv = function(w, t){ 42 return function(){ 43 if(typeof t === "undefined" || t-- > 0){ 44 setTimeout(interv, w); 45 try{ 46 func.call(null); 47 } 48 catch(e){ 49 t = 0; 50 throw e.toString(); 51 } 52 } 53 }; 54 }(wait, times); 55 56 setTimeout(interv, wait); 57 }; 58 59 function hasScrolled() { 60 var st = $(this).scrollTop(); 61 62 // Make sure they scroll more than delta 63 if(Math.abs(lastScrollTop - st) <= delta) 64 return; 65 66 if (st > lastScrollTop && st > headerHeight){ 67 // Scroll Down 68 var headerHeightTop = headerHeight + 5; 69 wrapper.css({ 'top' : '-' + headerHeightTop + 'px' }); 70 } else { 71 // Scroll Up 72 if(st + $(window).height() < $(document).height() && st > headerHeight) { 73 wrapper.css({ 'top' : '0' }); 74 } 75 } 76 77 lastScrollTop = st; 78 } 79 80}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.