Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mlbd/c7753cf913477c66b11d852fbf4a96a5 to your computer and use it in GitHub Desktop.
Save mlbd/c7753cf913477c66b11d852fbf4a96a5 to your computer and use it in GitHub Desktop.
var $header_menu_link = $('.appmax-header-menu ul li a');
if ($header_menu_link.is_exist()) {
$header_menu_link.on('click', function(e){
var href = $(this).attr("href");
if (/#/.test(this.href)) {
if ( $(href).length ) {
var minus = 100;
var offsetTop = href === "#" ? 0 : $(href).offset().top - minus;
$('body , html').stop().animate({
scrollTop: offsetTop,
}, 500);
e.preventDefault();
return false;
} else {
var pathname = window.location.pathname,
url = window.location.href,
get_home = url.substring(0, url.lastIndexOf("."));
get_home = get_home.substring(0, get_home.lastIndexOf("/"));
if ( href.length ) {
window.location.href = get_home + href;
} else {
window.location.href = get_home;
}
}
} // if href has hash
});
} // end header menu init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment