Skip to content

Instantly share code, notes, and snippets.

@Maden-maxi
Last active March 9, 2018 13:02
Show Gist options
  • Save Maden-maxi/9bfd79da98f1454635c68bf2e3aebd73 to your computer and use it in GitHub Desktop.
Save Maden-maxi/9bfd79da98f1454635c68bf2e3aebd73 to your computer and use it in GitHub Desktop.
$('a[href^="#"]').on('click', function(){
var elementClick = $(this).attr("href");
var destination = $(elementClick).offset().top;
var minusTop = 0;
switch(elementClick){
case "#services": minusTop = 90; break;
case "#portfolio": minusTop = 60; break;
case "#advantages": minusTop = 90; break;
case "#steps": minusTop = 60; break;
case "#price": minusTop = 60; break;
case "#contact": minusTop = 40; break;
}
$('html, body').animate( {scrollTop: destination-minusTop }, 1000 );
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment