Skip to content

Instantly share code, notes, and snippets.

@gbrennon
Created January 6, 2015 04:04
Show Gist options
  • Save gbrennon/b4c68b4d6c2b75733ccb to your computer and use it in GitHub Desktop.
Save gbrennon/b4c68b4d6c2b75733ccb to your computer and use it in GitHub Desktop.
agency js
$(function() {
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
// Highlight the top nav as scrolling occurs
$('body').scrollspy({
target: '.navbar-fixed-top'
})
// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
$('.navbar-toggle:visible').click();
});
@vitorbritto
Copy link

Tente colocar o primeiro operando entre parênteses: ($($anchor.attr('href')).offset().top). Ficando assim: ($($anchor.attr('href')).offset().top) - $topmenu.

Ou então, ao invés de atribuir o var $topmenu = $('.navbar-fixed-top').height();, passe um literal inteiro para a subtração. Ex.: scrollTop: $($anchor.attr('href')).offset().top - 130

Aí, você vai testando até encontrar o valor correto. Ou tente inspecionar a altura do .navbar-fixed-top e acrescente uns 40px. =]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment