pause intersection observer on toc expand
This commit is contained in:
parent
e1fed4dc9d
commit
2777fdfd63
|
@ -26,6 +26,7 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
|
|||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue