import { computed , Ref } from 'vue' ; import { Row } from '@/models/data/row' ; import useResize from './useResize' ; import useWheel from './useWheel' ; export default ( data ) => { const { rowHeight } = useResize ( ) ; const { scrollTop , rootHeight } = useWheel ( ) ; const preload = 1 ; const top = computed ( ( ) => { const index = Math . ceil ( scrollTop . value / rowHeight . value ) ; return index - preload > 0 ? index - preload : 0 ; } ) ; const bottom = computed ( ( ) => { const count = Math . ceil ( rootHeight . value / rowHeight . value ) ; const t = Math . ceil ( scrollTop . value / rowHeight . value ) + count + preload ; return t > data . value . length ? data . value . length : t ; } ) ; const inView = computed ( ( ) => data . value . slice ( top . value , bottom . value ) ) ; return { inView } ; } ;