Skip to content

Commit

Permalink
fix: update setimtoue for go to heading
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 20, 2020
1 parent fffe259 commit 8f6f994
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,23 @@ export class MarkdownRenderComponent implements OnInit, OnChanges, AfterViewInit
for (const chartInstance of this.chartInstances) {
chartInstance.clear();
}
setTimeout(() => {
this.renderChart();
this.gotoHeading();
}, 50);

const items = this.tocify.tocItems;
this.tocStr = this.renderToc(items).join('');
if (this.tocEl && this.tocEl.nativeElement) {
this.tocEl.nativeElement.innerHTML = this.tocStr;
}
this.tocify.reset();

setTimeout(() => this.renderChart(), 50);
setTimeout(() => this.gotoHeading(), 500);
}

private gotoHeading() {
this.route.fragment.subscribe((fragment: string) => {
if (!!fragment) {
const element = this.myElement.nativeElement.querySelector('#' + fragment);
console.log(element);
if (!!element) {
element.scrollIntoView();
}
Expand Down

0 comments on commit 8f6f994

Please sign in to comment.