1 import {Component} from "./component";
3 export class ApiNav extends Component {
4 private select!: HTMLSelectElement;
5 private sidebar!: HTMLElement;
6 private body!: HTMLElement;
9 this.select = this.$refs.select as HTMLSelectElement;
10 this.sidebar = this.$refs.sidebar;
11 this.body = this.$el.ownerDocument.documentElement;
12 this.select.addEventListener('change', () => {
13 const section = this.select.value;
14 const sidebarTarget = document.getElementById(`sidebar-header-${section}`);
15 const contentTarget = document.getElementById(`section-${section}`);
16 if (sidebarTarget && contentTarget) {
18 const sidebarPos = sidebarTarget.getBoundingClientRect().top - this.sidebar.getBoundingClientRect().top + this.sidebar.scrollTop;
19 this.sidebar.scrollTo({
20 top: sidebarPos - 120,
24 const bodyPos = contentTarget.getBoundingClientRect().top + this.body.scrollTop;