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

github.com/StaticMania/portio-hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrando Zhang <347830597@qq.com>2020-12-08 05:56:35 +0300
committerGitHub <noreply@github.com>2020-12-08 05:56:35 +0300
commited6f93aca9ddf4df496ba8715e04bd5813333254 (patch)
tree71f4bdbd277cd0ceef3bda64ba5d7e9474879e00
parent3e09b77eabeb3e0309d5a96819eea6aa0b7fdd05 (diff)
Fix: non-hash nav-item can be redirected
-rw-r--r--assets/js/script.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/assets/js/script.js b/assets/js/script.js
index 7e7f1aa..9123063 100644
--- a/assets/js/script.js
+++ b/assets/js/script.js
@@ -69,13 +69,16 @@ $(document).ready(function () {
// Smooth scrolling
var scrollLink = $(".scroll");
scrollLink.click(function (e) {
- e.preventDefault();
- $("body,html").animate(
- {
- scrollTop: $(this.hash).offset().top,
- },
- 1000
- );
+ let elem = $(this.hash)
+ if (elem.length) {
+ e.preventDefault();
+ $("body,html").animate(
+ {
+ scrollTop: elem.offset().top,
+ },
+ 1000
+ );
+ }
});
$(".navbar-nav>li>a").on("click", function () {