Merge pull request #2280 from hunicus/remove-listener

Remove doc scroll listener after navigating away
This commit is contained in:
softsimon 2022-08-11 21:23:40 +04:00 committed by GitHub
commit 251de2be11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,9 +50,7 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
document.getElementById( this.route.snapshot.fragment ).scrollIntoView();
}
}
window.addEventListener('scroll', function() {
that.desktopDocsNavPosition = ( window.pageYOffset > 182 ) ? "fixed" : "relative";
}, { passive: true} );
window.addEventListener('scroll', that.onDocScroll, { passive: true });
}, 1 );
}
@ -87,6 +85,14 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
});
}
ngOnDestroy(): void {
window.removeEventListener('scroll', this.onDocScroll);
}
onDocScroll() {
this.desktopDocsNavPosition = ( window.pageYOffset > 182 ) ? "fixed" : "relative";
}
anchorLinkClick( event: any ) {
let targetId = "";
if( event.target.nodeName === "A" ) {