import { onMounted , onUpdated , readonly } from 'vue' ; import { useStore } from '@/store' ; import useGanttRef from './useGanttRef' ; import useTableRef from './useTableRef' ; export default ( ) => { const { ganttRef } = useGanttRef ( ) ; const { tableRef } = useTableRef ( ) ; const store = useStore ( ) ; function tableWheelHandle ( e ) { const { deltaY } = e ; if ( ganttRef . value ) { ganttRef . value . scrollTop += deltaY ; } } function ganttWheelHandle ( ) { if ( tableRef . value ) { const st = ganttRef . value ?. scrollTop as number ; store . scrollTop . value = st ; tableRef . value . scrollTop = st ; } } function updateScrollBarHeight ( ) { if ( tableRef . value && ganttRef . value ) store . scrollBarHeight . value = tableRef . value . offsetHeight - ganttRef . value . clientHeight ; if ( tableRef . value ) store . rootHeight . value = tableRef . value . offsetHeight ; } onMounted ( updateScrollBarHeight ) ; onUpdated ( updateScrollBarHeight ) ; return { scrollTop : readonly ( store . scrollTop ) , rootHeight : readonly ( store . rootHeight ) , scrollBarHeight : readonly ( store . scrollBarHeight ) , tableWheelHandle , ganttWheelHandle } ; } ;