mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-11-21 19:42:52 +00:00
fix: if heading contains non English characters, cannot scroll properly (#228)
This commit is contained in:
parent
e781be1620
commit
89b8d152a9
1 changed files with 8 additions and 1 deletions
|
@ -21,8 +21,15 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
// Bitty scrolling links script
|
// Bitty scrolling links script
|
||||||
$("a[href^=\"#\"]").click(function(e) {
|
$("a[href^=\"#\"]").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
//BUG fix: https://github.com/victoriadrake/hugo-theme-introduction/issues/108
|
||||||
|
//
|
||||||
|
//let's get the right attribute `id` of the heading
|
||||||
|
v = e.target.href.replace(/http.*#/, '')
|
||||||
|
id = decodeURI(v)
|
||||||
|
|
||||||
$("html, body").animate({
|
$("html, body").animate({
|
||||||
scrollTop: $(document.getElementById(this.hash.substr(1))).offset().top
|
//scrollTop: $(document.getElementById(this.hash.substr(1))).offset().top
|
||||||
|
scrollTop: $(document.getElementById(id)).offset().top
|
||||||
}, 500);
|
}, 500);
|
||||||
$("#nav-menu").removeClass("is-active");
|
$("#nav-menu").removeClass("is-active");
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue