Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/vickylaixy/hugo-theme-introduction.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorhitzhangjie <hit.zhangjie@gmail.com>2020-08-02 01:47:51 +0300
committerGitHub <noreply@github.com>2020-08-02 01:47:51 +0300
commit89b8d152a9f6c83eef086747bcb29f86da92b9d0 (patch)
tree8a3e024bea13b223abaabb24b2a61fbd520ae0c0 /assets
parente781be1620c1f5f16044f035c265b937ba4971a7 (diff)
fix: if heading contains non English characters, cannot scroll properly (#228)
Diffstat (limited to 'assets')
-rw-r--r--assets/js/index.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 3b1a6b3..5705bd2 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -21,8 +21,15 @@ document.addEventListener("DOMContentLoaded", function () {
// Bitty scrolling links script
$("a[href^=\"#\"]").click(function(e) {
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({
- 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);
$("#nav-menu").removeClass("is-active");
return true;