Skip to content

Commit

Permalink
fix: jumps to selected annotation region (DEV-4542)
Browse files Browse the repository at this point in the history
  • Loading branch information
irmastnt committed Jan 29, 2025
1 parent 7ebac68 commit 5641a3a
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@ export class AnnotationTabComponent implements OnInit, OnDestroy {
this._subscription.unsubscribe();
}

private _scrollToRegion(iri: string) {
const region = document.getElementById(iri);
if (region) {
region.scrollIntoView({
behavior: 'smooth',
block: 'center',
});
}
}

trackAnnotationByFn = (index: number, item: DspResource) => `${index}-${item.res.id}`;
protected readonly RouteConstants = RouteConstants;

private _scrollToRegion(iri: string) {
const elements = document.querySelectorAll(`#${CSS.escape(iri)}`);

Array.from(elements).forEach(element => {
if (!(element as HTMLElement).classList.contains('region')) {
(element as HTMLElement).scrollIntoView({
behavior: 'smooth',
});
return;
}
});
}
}

0 comments on commit 5641a3a

Please sign in to comment.