Skip to content

Instantly share code, notes, and snippets.

@Ferrmolina
Last active July 11, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ferrmolina/84f881a3bd83afdcbf46 to your computer and use it in GitHub Desktop.
Save Ferrmolina/84f881a3bd83afdcbf46 to your computer and use it in GitHub Desktop.
Fixed header, with animation.
var header = $('#index');
$(function(){ header.data('size','grande'); });
$(window).scroll(function(){
if ($(document).scrollTop() > 150) {
if (header.data('size') == 'grande') {
header.data('size','chico');
header.stop().addClass('header-top').animate({ padding:'5px 0px 5px 0px' }, 600);
}
} else {
if (header.data('size') == 'chico') {
header.data('size','grande');
header.stop().removeClass('header-top').animate({ padding:'20px 0px 20px 0px' }, 600);
}
}
});
$(document).ready(function(){
$(function(){
$('.slide:gt(0)').hide();
setInterval(function(){
$('.slide:first-child').fadeOut(1200).next('.slide').fadeIn(1200).end().appendTo('#slider');
}, 4500);
});
});
$('#btn-menu').change(function() {
if($(this).is(":checked")) {
$('#selector').html('<img src="css/images/close-icon.png" height="35" width="35" alt="Close Icon" />');
} else {
$('#selector').html('<img src="css/images/nav-icon.png" height="45" width="45" alt="Menu Icon" />');
}
});
$(function(){ header.data('size','grande'); });
$(window).scroll(function(){
if ($(document).scrollTop() > 150) {
if (header.data('size') == 'grande') {
header.data('size','chico');
header.stop().addClass('header-top').animate({ padding:'5px 0px 5px 0px' }, 600);
}
} else {
if (header.data('size') == 'chico') {
header.data('size','grande');
header.stop().removeClass('header-top').animate({ padding:'20px 0px 20px 0px' }, 600);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment