Skip to content
Snippets Groups Projects
Commit 52f7abb4 authored by khawkins98's avatar khawkins98
Browse files

Improve smooth scroll to show hash in URL

Also remove redundant function
parent ffca1760
No related branches found
No related tags found
No related merge requests found
......@@ -53,12 +53,16 @@
return true; //exit
}
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
var target = $(this.hash),
targetName = this.hash;
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 40
}, 1000);
}, {
duration: 1000,
complete: function(){ window.location.hash = targetName; }
});
return false;
}
}
......
......@@ -437,22 +437,6 @@ $.fn.foundationExtendEBI = function() {
};
});
// Smooth scroll anchor links for jQuery users
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
window.location.hash = this.hash;
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 40
}, 1000);
return false;
}
}
});
});
}
}(jQuery));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment