浏览代码

Remove IntersectionObserver usage; fix #395

shalvah 3 年之前
父节点
当前提交
8c66bfd3db
共有 1 个文件被更改,包括 0 次插入22 次删除
  1. 0 22
      resources/js/theme-default.js

+ 0 - 22
resources/js/theme-default.js

@@ -3,28 +3,6 @@ document.addEventListener('DOMContentLoaded', function() {
         window.location.hash = `#${id}`;
     };
 
-    const throttledUpdateHash = _.throttle(updateHash, 200);
-
-    const observer = new IntersectionObserver((entries) => {
-        // If intersectionRatio is 0, the target is out of view
-        // and we do not need to do anything.
-        if (entries[0].intersectionRatio <= 0) {
-            return;
-        }
-
-        throttledUpdateHash(entries[0].target.id);
-    }, {
-        rootMargin: '-8% 0px -8% 0px', // shrink the intersection viewport
-        threshold: 1.0, // trigger at 100% visibility
-    });
-
-    function makeObserver(elem) {
-        return observer.observe(elem);
-    }
-
-    const titles = document.querySelectorAll('.content h1, .content h2');
-    Array.from(titles).forEach(makeObserver);
-
     const navButton = document.getElementById('nav-button');
     const menuWrapper = document.querySelector('.tocify-wrapper');
     function toggleSidebar() {