(entries)
| 911 | } |
| 912 | |
| 913 | onIntersect(entries) { |
| 914 | if (this.isIntersectionObserverActive === false) { |
| 915 | return; |
| 916 | } |
| 917 | |
| 918 | entries.forEach((entry) => { |
| 919 | if (entry.isIntersecting && entry.intersectionRatio > 0) { |
| 920 | const oldNavEl = this.shadowRoot.querySelector('.nav-bar-tag.active, .nav-bar-path.active, .nav-bar-info.active, .nav-bar-h1.active, .nav-bar-h2.active, .operations.active'); |
| 921 | const newNavEl = this.shadowRoot.getElementById(`link-${entry.target.id}`); |
| 922 | |
| 923 | // Add active class in the new element |
| 924 | if (newNavEl) { |
| 925 | if (this.updateRoute === 'true') { |
| 926 | this.replaceHistoryState(entry.target.id); |
| 927 | } |
| 928 | newNavEl.scrollIntoView({ behavior: this.scrollBehavior, block: 'center' }); |
| 929 | newNavEl.classList.add('active'); |
| 930 | newNavEl.part.add('section-navbar-active-item'); |
| 931 | } |
| 932 | |
| 933 | // Remove active class from previous element |
| 934 | // if it is different from the new one (edge case on loading in read render style) |
| 935 | if (oldNavEl && oldNavEl !== newNavEl) { |
| 936 | oldNavEl.classList.remove('active'); |
| 937 | oldNavEl.part.remove('section-navbar-active-item'); |
| 938 | } |
| 939 | } |
| 940 | }); |
| 941 | } |
| 942 | |
| 943 | // Called by anchor tags created using markdown |
| 944 | handleHref(e) { |
no test coverage detected