in client/src/components/translation-selector/word-scroll-list.ts [231:247]
private centerWords() {
if (!this.scrollContent || this.selectedWordIndex < 0) {
return;
}
const scrollContainer = this.hostElement.nativeElement as HTMLElement;
const scrollContent = this.scrollContent.nativeElement;
const items = scrollContent.getElementsByTagName('li');
if (!items || this.selectedWordIndex >= items.length) {
return;
}
const containerBounds = scrollContainer.getBoundingClientRect();
const centerX = containerBounds.left + containerBounds.width * 0.5;
const currentItem = items[this.selectedWordIndex];
const currentItemBounds = currentItem.getBoundingClientRect();
const currentItemCenterX = currentItemBounds.left + currentItemBounds.width * 0.5;
this.setScrollPosition(centerX - currentItemCenterX);
}