import { ScrollOperator } from '@/lib/operator/ScrollOperator'; import { Store } from '@/lib/store'; export const useScroll = (store: Store) => { const scrollOperator = new ScrollOperator(store); return { // 垂直滚动 目前支持虚拟滚动 vertical: () => (e: Event) => { scrollOperator.scrollY((e.target as Element).scrollTop); }, // 水平滚动 目前不支持虚拟滚动 horizontal: () => (e: Event) => { const { width } = (e.target as Element).getBoundingClientRect(); scrollOperator.scrollX((e.target as Element).scrollLeft, width); }, }; };