Skip to content

Instantly share code, notes, and snippets.

@luisfelipe-dev
Last active November 2, 2017 13:29
Show Gist options
  • Select an option

  • Save luisfelipe-dev/05d842dcdafd42175ae7939ec8630147 to your computer and use it in GitHub Desktop.

Select an option

Save luisfelipe-dev/05d842dcdafd42175ae7939ec8630147 to your computer and use it in GitHub Desktop.
Efeito Scroll muito fácil de fazer!
$('.heading a').click(function(e){ //COLOCAR A CLASSE DO MENU NO LUGAR DO '.heading'
e.preventDefault();
var id = $(this).attr('href'),
targetOffset = $(id).offset().top,
menuHeight = $('.heading').innerHeight(); //COLOCAR A CLASSE DO MENU NO LUGAR DO '.heading'
$('html,body').animate({
scrollTop: targetOffset - menuHeight
},500); //500 = VELOCIDADE DO SCROLL
});
-- ATUALIZADO:
//Anchor link
var _rys = jQuery.noConflict();
_rys('.main-menu a, .scroll-down-page a, .colum-vantagens a').click(function(e){
var id = _rys(this).attr('href'),
targetOffset = _rys(id).offset().top,
menuHeight = _rys('header').innerHeight(); //COLOCAR A CLASSE DO MENU NO LUGAR DO '.heading'
_rys('html,body').animate({
scrollTop: targetOffset - menuHeight
},800); //500 = VELOCIDADE DO SCROLL
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment