Fix anchor links when navigating to current anchor

This commit is contained in:
hunicus
2022-03-11 19:06:06 -05:00
parent 2d4b824862
commit b71df774f5
4 changed files with 19 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ import { Env, StateService } from 'src/app/services/state.service';
import { Observable, merge, of } from 'rxjs';
import { SeoService } from 'src/app/services/seo.service';
import { tap } from 'rxjs/operators';
import { ActivatedRoute } from "@angular/router";
import { restApiDocsData, wsApiDocsData } from './api-docs-data';
@Component({
@@ -28,6 +29,7 @@ export class ApiDocsComponent implements OnInit {
constructor(
private stateService: StateService,
private seoService: SeoService,
private route: ActivatedRoute,
) { }
ngAfterViewInit() {
@@ -70,6 +72,13 @@ export class ApiDocsComponent implements OnInit {
});
}
scrollSameId( event: any ) {
const targetId = event.target.hash.substring(1);
if( this.route.snapshot.fragment === targetId ) {
document.getElementById( targetId ).scrollIntoView();
}
}
wrapUrl(network: string, code: any, websocket: boolean = false) {
let curlResponse = [];