Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/primefaces/primeng
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Feb 7, 2024
2 parents de3ffd6 + 86bda4a commit 87b5b24
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/app/showcase/layout/doc/app.docsection-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,25 @@ export class AppDocSectionNavComponent implements OnInit, OnDestroy {
return [...Array.from(this.document.querySelectorAll(':is(h1,h2,h3).doc-section-label'))].filter((el: any) => DomHandler.isVisible(el));
}

onScroll() {
onScroll() {
if (isPlatformBrowser(this.platformId) && this.nav) {
if (!this.isScrollBlocked) {
if (typeof document !== undefined) {
const labels = this.getLabels();
const windowScrollTop = DomHandler.getWindowScrollTop();

labels.forEach((label) => {
const { top } = DomHandler.getOffset(label);
const threshold = this.getThreshold(label);

if (top - threshold <= windowScrollTop) {
const link = DomHandler.findSingle(label, 'a');
this.activeId = link.id;
}
});
}
this.zone.run(() => {
if (typeof document !== 'undefined') {
const labels = this.getLabels();
const windowScrollTop = DomHandler.getWindowScrollTop();

labels.forEach((label) => {
const { top } = DomHandler.getOffset(label);
const threshold = this.getThreshold(label);

if (top - threshold <= windowScrollTop) {
const link = DomHandler.findSingle(label, 'a');
this.activeId = link.id;
}
});
}
});
}

clearTimeout(this.scrollEndTimer);
Expand Down

0 comments on commit 87b5b24

Please sign in to comment.