Created
January 8, 2014 23:24
-
-
Save ramzesimus/8326653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// decreases header size when user scrolls down | |
avia_header_size(); | |
//check if the browser supports element rotation | |
function avia_header_size() | |
{ | |
var win = $(window), | |
header = $('.fixed_header #header'), | |
//logo = header.find('.logo img'), | |
logo = $('#header_main .container .logo img, #header_main .container .logo a'), | |
elements = $('#header_main .container, .main_menu ul:first-child > li > a:not(.avia_mega_div a)'), | |
el_height = $(elements).filter(':first').height(), | |
isMobile = 'ontouchstart' in document.documentElement, | |
scroll_top = $('#scroll-top-link'), | |
set_height = function() | |
{ | |
var st = win.scrollTop(), newH = 0; | |
if(st < el_height/2) | |
{ | |
newH = el_height - st; | |
header.removeClass('header-scrolled'); | |
} | |
else | |
{ | |
newH = el_height/2; | |
header.addClass('header-scrolled'); | |
} | |
elements.css({'height': newH + 'px', 'lineHeight': newH + 'px'}); | |
logo.css({'maxHeight': newH + 'px'}); | |
} | |
if(!header.length) return false; | |
if(isMobile) | |
{ | |
return false; | |
} | |
win.scroll(set_height); | |
set_height(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment