Files
InvokeAI/invokeai/frontend/web/src/features/gallery/util/getScrollToIndexAlign.ts
psychedelicious 189c430e46 chore(ui): format
Lots of changed bc the line length is now 120. May as well do it now.
2024-01-28 19:57:53 +11:00

15 lines
442 B
TypeScript

import type { ListRange } from 'react-virtuoso';
/**
* Gets the alignment for react-virtuoso's scrollToIndex function.
* @param index The index of the item.
* @param range The range of items currently visible.
* @returns
*/
export const getScrollToIndexAlign = (index: number, range: ListRange): 'start' | 'end' => {
if (index > (range.endIndex - range.startIndex) / 2 + range.startIndex) {
return 'end';
}
return 'start';
};