Files
Netcatty/domain/sftpVirtualList.ts
T
陈大猫 4b4b7d4449 Improve SFTP sorting and keyboard navigation (#2314)
* improve SFTP sorting and keyboard navigation

* fix SFTP keyboard actions for empty views

* fix SFTP file row context menu

* fix folders-first kind sorting
2026-07-19 11:34:47 +08:00

23 lines
549 B
TypeScript

interface SftpVirtualListScrollInput {
itemIndex: number;
rowHeight: number;
currentScrollTop: number;
viewportHeight: number;
}
export const getSftpVirtualListScrollTop = ({
itemIndex,
rowHeight,
currentScrollTop,
viewportHeight,
}: SftpVirtualListScrollInput): number => {
const rowTop = itemIndex * rowHeight;
const rowBottom = rowTop + rowHeight;
if (rowTop < currentScrollTop) return rowTop;
if (rowBottom > currentScrollTop + viewportHeight) {
return rowBottom - viewportHeight;
}
return currentScrollTop;
};