UNPKG

vue-gantt-3

Version:

A gantt component for Vue 3

54 lines (53 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const useTableScroll = ({ tableBodyView, tableBodyVerticalScrollViewport, emitTriggerGanttViewScroll }) => { const scrollFromGanttView = vue.ref(false); vue.onBeforeUnmount(() => { var _a, _b; (_a = tableBodyView.value) == null ? void 0 : _a.removeEventListener("wheel", bodyWheel); (_b = tableBodyVerticalScrollViewport.value) == null ? void 0 : _b.removeEventListener("scroll", verticalScrollViewportScroll); }); const verticalScrollViewportScroll = () => { var _a; if (scrollFromGanttView.value) { scrollFromGanttView.value = false; } else { emitTriggerGanttViewScroll({ top: (_a = tableBodyVerticalScrollViewport.value) == null ? void 0 : _a.scrollTop }); } }; const bodyWheel = (e) => { var _a, _b; e.preventDefault(); if (!tableBodyVerticalScrollViewport.value) return; if (Math.abs(e.deltaY) < 3) return; scrollFromGanttView.value = false; const scrollSpeed = 100; const scrollDistance = e.deltaY > 0 ? scrollSpeed : -100; const scrollTop = ((_a = tableBodyVerticalScrollViewport.value) == null ? void 0 : _a.scrollTop) + scrollDistance; (_b = tableBodyVerticalScrollViewport.value) == null ? void 0 : _b.scrollTo({ top: scrollTop }); }; const scrollTo = (options, onWheel) => { var _a, _b, _c; scrollFromGanttView.value = true; if (onWheel) { (_a = tableBodyVerticalScrollViewport.value) == null ? void 0 : _a.scrollTo(options); } else { (_b = tableBodyVerticalScrollViewport.value) == null ? void 0 : _b.scrollTo(options); if (((_c = tableBodyVerticalScrollViewport.value) == null ? void 0 : _c.scrollTop) === options.top) { scrollFromGanttView.value = false; } } }; return { scrollTo, bodyWheel, verticalScrollViewportScroll }; }; exports.useTableScroll = useTableScroll; //# sourceMappingURL=useTableScroll.js.map