Skip to content

Instantly share code, notes, and snippets.

@enlacee
Created August 29, 2017 22:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlacee/30f5189d1d15602cb9914b300ea1d670 to your computer and use it in GitHub Desktop.
Save enlacee/30f5189d1d15602cb9914b300ea1d670 to your computer and use it in GitHub Desktop.
hacer scroll con el tamaño de cabecera
function getHeightHeader() {
var height = 0;
if ($('.header-page').length === 1) {
$headerPage = $('.header-page');
if ($headerPage.css('position') === 'fixed') {
height = $headerPage.height();
}
}
return height;
}
var sizeHeaderDesktop = getHeightHeader();
function setScrollContent(domJquerySelected){
$sectionJqueryDom = domJquerySelected;
$("html, body").animate(
{
scrollTop: $sectionJqueryDom.offset().top - sizeHeaderDesktop
},
{
duration: 1000,
complete: function() {
if (sizeHeaderDesktop !== getHeightHeader()) {
sizeHeaderDesktop = getHeightHeader();
$("html, body").animate({scrollTop: $sectionJqueryDom.offset().top - sizeHeaderDesktop});
}
}
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment