feat: quick switcher
This commit is contained in:
@@ -25,13 +25,19 @@ const rowVirtualizer = useVirtualizer(computed(() => ({
|
||||
const virtualRows = computed(() => rowVirtualizer.value.getVirtualItems());
|
||||
const totalSize = computed(() => rowVirtualizer.value.getTotalSize());
|
||||
|
||||
defineExpose({
|
||||
scrollToIndex: (index: number, options?: { align?: 'start' | 'center' | 'end' }) => {
|
||||
rowVirtualizer.value.scrollToIndex(index, options);
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => props.items, () => {
|
||||
rowVirtualizer.value.measure();
|
||||
}, { deep: false });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :style="{ height: `${totalSize}px`, width: '100%', position: 'relative' }">
|
||||
<div :style="{ height: `${totalSize}px`, width: '100%', position: 'relative' }" v-bind="$attrs">
|
||||
<div v-for="virtualRow in virtualRows" :key="(virtualRow.key as any | number)" :style="{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
|
||||
Reference in New Issue
Block a user