getUpdatedOffsetForIndex({
    align = 'auto',
    containerSize,
    currentOffset,
    targetIndex,
  }: GetUpdatedOffsetForIndex): number {
    if (containerSize <= 0) {
      return 0;
    }

    const datum = this.getSizeAndPositionOfCell(targetIndex);
    const maxOffset = datum.offset;
    const minOffset = maxOffset - containerSize + datum.size;

    let idealOffset;

    switch (align) {
      case 'start':
        idealOffset = maxOffset;
        break;
      case 'end':
        idealOffset = minOffset;
        break;
      case 'center':
        idealOffset = maxOffset - (containerSize - datum.size) / 2;
        break;
      default:
        idealOffset = Math.max(minOffset, Math.min(maxOffset, currentOffset));
        break;
    }

    const totalSize = this.getTotalSize();

    return Math.max(0, Math.min(totalSize - containerSize, idealOffset));
  }
Determines a new offset that ensures a certain cell is visible, given the current offset.
If the cell is already visible then the current offset will be returned.
If the current offset is too great or small, it will be adjusted just enough to ensure the specified index is visible.

@param align Desired alignment within container; one of "auto" (default), "start", or "end"
@param containerSize Size (width or height) of the container viewport
@param currentOffset Container's current (x or y) offset
@param totalSize Total size (width or height) of all cells
@return Offset to use to ensure the specified cell is visible