Forráskód Böngészése

Add scroll to element

Riccardo Balbo 3 éve
szülő
commit
e67b1fa9b5
1 módosított fájl, 3 hozzáadás és 3 törlés
  1. 3 3
      static/js/utils.js

+ 3 - 3
static/js/utils.js

@@ -121,7 +121,7 @@ const updateFloatingHeader = () => {
 
 document.addEventListener("scroll", updateFloatingHeader);
 
-const scrollTo = (contentAnchor) => {
+window.scrollToElement = (contentAnchor) => {
     const anchorBound = contentAnchor.getBoundingClientRect();
     const floatingHBound = floatingHeader.getBoundingClientRect();
     // contentAnchor.scrollIntoView({
@@ -143,10 +143,10 @@ window.addEventListener("DOMContentLoaded", function () {
         window.scrollTo(0, 0);
         if (location.hash&&location.hash!="#") {
             const contentAnchor = document.querySelector(location.hash);
-            if(contentAnchor)scrollTo(contentAnchor);
+            if(contentAnchor)window.scrollToElement(contentAnchor);
         } else {
             const contentAnchor = document.querySelector("#content");
-            if (contentAnchor) scrollTo(contentAnchor);
+            if (contentAnchor) window.scrollToElement(contentAnchor);
         }
     };