Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save DevShahidul/27e5122e73248d6c2ce6d089cba55a95 to your computer and use it in GitHub Desktop.

Select an option

Save DevShahidul/27e5122e73248d6c2ce6d089cba55a95 to your computer and use it in GitHub Desktop.
(function($){
$(function(){
$('.main-nav ul li a').on('click', function(e) {
$(".main-nav ul li").removeClass("current-menu-item");
$(this).parent().addClass("current-menu-item");
if($(window).width() <= 767 ){
$(".navigation-wrapper").removeClass("navShown");
$(".phone-nav").removeClass("change");
}
smooth_scroll_to(this.hash, e);
});
})
})(jQuery)
$(window).on('load',function() {
scroll(0, 0);
// takes care of some browsers issue
setTimeout(function(){scroll(0, 0);},1);
smooth_scroll_to(window.location.hash);
});
function smooth_scroll_to(hash, e) {
if(hash === '') {
return false;
} else {
if($(hash).length > 0) {
if(typeof e !== 'undefined') {
e.preventDefault();
history.pushState(null, null, $(e.target).attr('href'));
}
$('html, body').animate({
scrollTop: $(hash).offset().top - 83
}, 2000 );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment