diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts index 25e451b5e..460a7777f 100644 --- a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts @@ -24,8 +24,9 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O @Input() anchorFieldsetId: string; tocentries: ToCEntry[] = null; - + private _intersectionObserver: IntersectionObserver; + pauseIntersectionObserver: boolean = false; private _tocentrySelected: ToCEntry = null; get tocentrySelected() { @@ -152,7 +153,7 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O debounceTime(300), distinctUntilChanged(), ).subscribe(x => { - if (x.isIntersecting) { + if (x.isIntersecting && !this.pauseIntersectionObserver) { const target_id = x.target.id; if (this._isVisible(target_id)) { this.tocentrySelected = TableOfContentsComponent._findTocEntryById(target_id, this.tocentries); @@ -337,8 +338,10 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O } onToCentrySelected(entry: ToCEntry = null, execute: boolean = true) { + this.pauseIntersectionObserver = true; this.tocentrySelected = entry; this.entrySelected.emit({ entry: entry, execute: execute }); + setTimeout(() => this.pauseIntersectionObserver = false, 1000); } /**