private alignItems()

in client/src/components/scroll-list/scroll-list.ts [264:283]


  private alignItems() {
    if (!this.scrollContent || this.currentItem < 0 || this.itemAlignment !== 'center') {
      return;
    }
    const scrollContainer = this.hostElement.nativeElement as HTMLElement;
    const scrollContent = this.scrollContent.nativeElement;
    const items = scrollContent.getElementsByTagName('li');
    if (!items || this.currentItem >= items.length) {
      return;
    }
    const currentItem = items[this.currentItem];
    if (!currentItem) {
      return;
    }
    const containerBounds = scrollContainer.getBoundingClientRect();
    const centerX = containerBounds.left + containerBounds.width * 0.5;
    const currentItemBounds = currentItem.getBoundingClientRect();
    const currentItemCenterX = currentItemBounds.left + currentItemBounds.width * 0.5;
    this.setScrollPosition(centerX - currentItemCenterX);
  }