function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 30);
}
}
// call this function after event fire offsetAnchor() //
$(document).ready(function(){
$("a").on('click', function(event) {
window.location.hash = '';
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
window.location.hash = hash;
offsetAnchor();
});
}
});
});