mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 19:46:33 +00:00
feat: start on content tab env focused design
This commit is contained in:
@@ -7,7 +7,7 @@ export interface ScrollViewportOptions {
|
||||
}
|
||||
|
||||
export interface VirtualScrollOptions {
|
||||
itemHeight: number
|
||||
itemHeight: number | Ref<number>
|
||||
bufferSize?: number
|
||||
initialItemCount?: number
|
||||
enabled?: Ref<boolean>
|
||||
@@ -140,6 +140,9 @@ export function useVirtualScroll<T>(items: Ref<T[]>, options: VirtualScrollOptio
|
||||
onNearEnd,
|
||||
nearEndThreshold = 0.2,
|
||||
} = options
|
||||
const resolvedItemHeight = computed(() =>
|
||||
typeof itemHeight === 'number' ? itemHeight : itemHeight.value,
|
||||
)
|
||||
|
||||
const {
|
||||
listContainer,
|
||||
@@ -152,7 +155,7 @@ export function useVirtualScroll<T>(items: Ref<T[]>, options: VirtualScrollOptio
|
||||
onScroll: checkNearEnd,
|
||||
})
|
||||
|
||||
const totalHeight = computed(() => items.value.length * itemHeight)
|
||||
const totalHeight = computed(() => items.value.length * resolvedItemHeight.value)
|
||||
|
||||
const visibleRange = computed(() => {
|
||||
if (enabled && !enabled.value) {
|
||||
@@ -163,8 +166,8 @@ export function useVirtualScroll<T>(items: Ref<T[]>, options: VirtualScrollOptio
|
||||
return { start: 0, end: Math.min(items.value.length, initialItemCount) }
|
||||
}
|
||||
|
||||
const start = Math.floor(relativeScrollTop.value / itemHeight)
|
||||
const visibleCount = Math.ceil(viewportHeight.value / itemHeight)
|
||||
const start = Math.floor(relativeScrollTop.value / resolvedItemHeight.value)
|
||||
const visibleCount = Math.ceil(viewportHeight.value / resolvedItemHeight.value)
|
||||
const rangeSize = visibleCount + bufferSize * 2
|
||||
|
||||
const rangeStart = Math.min(
|
||||
@@ -180,7 +183,7 @@ export function useVirtualScroll<T>(items: Ref<T[]>, options: VirtualScrollOptio
|
||||
})
|
||||
|
||||
const visibleTop = computed(() =>
|
||||
enabled && !enabled.value ? 0 : visibleRange.value.start * itemHeight,
|
||||
enabled && !enabled.value ? 0 : visibleRange.value.start * resolvedItemHeight.value,
|
||||
)
|
||||
|
||||
const visibleItems = computed(() =>
|
||||
|
||||
Reference in New Issue
Block a user