浏览代码

Add go-to-overview button in top banner

Riccardo Balbo 4 年之前
父节点
当前提交
615a8e1eda
共有 3 个文件被更改,包括 17 次插入7 次删除
  1. 1 1
      layouts/partials/features.html
  2. 7 1
      layouts/partials/showcaseBanner.html
  3. 9 5
      static/js/utils.js

+ 1 - 1
layouts/partials/features.html

@@ -1,4 +1,4 @@
-<h1>jMonkeyEngine</h1>
+<h1 id="features">jMonkeyEngine</h1>
 <section class="list hlist responsive responsiveWidth features">
     <article>
         <h1><i class="fas fa-shapes"></i> Powerful Graphics</h1>

+ 7 - 1
layouts/partials/showcaseBanner.html

@@ -14,7 +14,13 @@
       <br />
       <br />
       <br />
-      <a href="/start/"><button  id="startbtn" class="highlightedCl"><i class="fas fa-rocket"></i> Get Started... </button></a>
+
+      <a href="/start/"><button  id="startbtn" class="highlightedCl"><i class="fas fa-rocket"></i> Get Started </button></a>
+
+      <a href="/#features" title="overview"><button id="startbtn"   class="highlightedCl"><i class="fas fa-question-circle"></i></button></a>
+      
+
+      
         <br />
         <br />
     </div>

+ 9 - 5
static/js/utils.js

@@ -139,20 +139,24 @@ const scrollTo = (contentAnchor) => {
 window.addEventListener("DOMContentLoaded", function () {
     updateFloatingHeader();
 
-
-    setTimeout(() => {
+    const scrollNow=()=>{
         window.scrollTo(0, 0);
-        if (location.hash) {
+        if (location.hash&&location.hash!="#") {
             const contentAnchor = document.querySelector(location.hash);
             if(contentAnchor)scrollTo(contentAnchor);
         } else {
             const contentAnchor = document.querySelector("#content");
             if (contentAnchor) scrollTo(contentAnchor);
         }
-    }, 1);
-
+    };
 
+    setTimeout(() => {
+        scrollNow();
+    }, 1);
 
+    window.addEventListener("hashchange", function () {
+        if(location.hash&&location.hash!="#")scrollNow();
+    });
 
 
     document.querySelectorAll("[toggle]").forEach(el => {