vxe-gantt 3.8.0 → 3.9.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { defineVxeComponent } from '../../ui/src/comp';
2
2
  import { VxeUI } from '@vxe-ui/core';
3
+ import { getDefaultConfig } from '../../ui/src/utils';
3
4
  import { setScrollTop, setScrollLeft, removeClass, addClass, hasClass } from '../../ui/src/dom';
4
5
  import { getRefElem, getTaskBarLeft, getTaskBarWidth, hasMilestoneTask, getTaskType, hasSubviewTask } from './util';
5
6
  import { VxeGanttDependencyType } from './static';
@@ -7,7 +8,8 @@ import XEUtils from 'xe-utils';
7
8
  import GanttViewHeaderComponent from './gantt-header';
8
9
  import GanttViewBodyComponent from './gantt-body';
9
10
  import GanttViewFooterComponent from './gantt-footer';
10
- const { globalEvents } = VxeUI;
11
+ const { getConfig, domUtils, scrollbarUtils, globalResize, globalEvents, renderEmptyElement } = VxeUI;
12
+ const { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils;
11
13
  const { FinishToStart, StartToFinish, StartToStart, FinishToFinish } = VxeGanttDependencyType;
12
14
  const sourceType = 'gantt';
13
15
  const secondMs = 1000;
@@ -36,7 +38,12 @@ function createInternalData() {
36
38
  startIndex: 0,
37
39
  endIndex: 0
38
40
  },
39
- // 最后滚动位置
41
+ // 滚动条
42
+ // scrollObserver: undefined,
43
+ // isThumbDrag: false,
44
+ thumbDragOffset: 0,
45
+ yThumbTop: 0,
46
+ xThumbLeft: 0,
40
47
  lastScrollTop: 0,
41
48
  lastScrollLeft: 0
42
49
  };
@@ -58,6 +65,9 @@ function createReactData() {
58
65
  // 最后滚动时间戳
59
66
  lastScrollTime: 0,
60
67
  lazScrollLoading: false,
68
+ // 滚动条
69
+ yThumbHeight: 0,
70
+ xThumbWidth: 0,
61
71
  scrollVMLoading: false,
62
72
  scrollYHeight: 0,
63
73
  scrollYTop: 0,
@@ -1223,6 +1233,8 @@ function updateStyle($xeGanttView) {
1223
1233
  const $xeGantt = $xeGanttView.$xeGantt;
1224
1234
  const reactData = $xeGanttView.reactData;
1225
1235
  const internalData = $xeGanttView.internalData;
1236
+ const ganttReactData = $xeGantt.reactData;
1237
+ const { showLeftView } = ganttReactData;
1226
1238
  const { scrollbarWidth, scrollbarHeight, headerGroups, tableColumn } = reactData;
1227
1239
  const { elemStore, visibleColumn } = internalData;
1228
1240
  const $xeTable = internalData.xeTable;
@@ -1233,7 +1245,7 @@ function updateStyle($xeGanttView) {
1233
1245
  if (!$xeGantt) {
1234
1246
  return;
1235
1247
  }
1236
- const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1248
+ const scrollYVisible = $xeGanttView.computeScrollYVisible;
1237
1249
  const scrollbarXToTop = $xeGantt.computeScrollbarXToTop;
1238
1250
  const scrollbarYToLeft = $xeGantt.computeScrollbarYToLeft;
1239
1251
  const xLeftCornerEl = $xeGanttView.$refs.refScrollXLeftCornerElem;
@@ -1251,7 +1263,8 @@ function updateStyle($xeGanttView) {
1251
1263
  tFooterHeight = tableInternalData.tFooterHeight;
1252
1264
  }
1253
1265
  let yScrollbarVisible = 'visible';
1254
- if (scrollbarYToLeft || (scrollbarOpts.y && scrollbarOpts.y.visible === false)) {
1266
+ const hideYScroll = scrollYVisible === false || scrollYVisible === 'hidden';
1267
+ if (hideYScroll || (scrollbarYToLeft && showLeftView)) {
1255
1268
  osbWidth = 0;
1256
1269
  yScrollbarVisible = 'hidden';
1257
1270
  }
@@ -1365,6 +1378,7 @@ function handleLazyRecalculate($xeGanttView) {
1365
1378
  const resizeOpts = $xeTable.computeResizeOpts;
1366
1379
  refreshDelay = resizeOpts.refreshDelay || refreshDelay;
1367
1380
  }
1381
+ $xeGanttView.updateScrollbar();
1368
1382
  if (rceTimeout) {
1369
1383
  clearTimeout(rceTimeout);
1370
1384
  if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
@@ -1624,92 +1638,6 @@ function handleScrollData($xeGanttView, isRollY, isRollX, scrollTop, scrollLeft)
1624
1638
  reactData.lastScrollTime = Date.now();
1625
1639
  checkLastSyncScroll($xeGanttView, isRollX, isRollY);
1626
1640
  }
1627
- function handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, scrollTop, scrollLeft) {
1628
- const $xeGantt = $xeGanttView.$xeGantt;
1629
- const internalData = $xeGanttView.internalData;
1630
- const $xeTable = internalData.xeTable;
1631
- const { lastScrollLeft, lastScrollTop } = internalData;
1632
- const xHandleEl = $xeGanttView.$refs.refScrollXHandleElem;
1633
- const yHandleEl = $xeGanttView.$refs.refScrollYHandleElem;
1634
- if (!xHandleEl || !yHandleEl) {
1635
- return;
1636
- }
1637
- if (!$xeTable) {
1638
- return;
1639
- }
1640
- const bodyHeight = yHandleEl.clientHeight;
1641
- const bodyWidth = xHandleEl.clientWidth;
1642
- const scrollHeight = yHandleEl.scrollHeight;
1643
- const scrollWidth = xHandleEl.scrollWidth;
1644
- let isTop = false;
1645
- let isBottom = false;
1646
- let isLeft = false;
1647
- let isRight = false;
1648
- let direction = '';
1649
- let isTopBoundary = false;
1650
- let isBottomBoundary = false;
1651
- let isLeftBoundary = false;
1652
- let isRightBoundary = false;
1653
- if (isRollX) {
1654
- const xThreshold = $xeTable.computeScrollXThreshold;
1655
- isLeft = scrollLeft <= 0;
1656
- if (!isLeft) {
1657
- isRight = scrollLeft + bodyWidth >= scrollWidth - 1;
1658
- }
1659
- if (scrollLeft > lastScrollLeft) {
1660
- direction = 'right';
1661
- if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
1662
- isRightBoundary = true;
1663
- }
1664
- }
1665
- else {
1666
- direction = 'left';
1667
- if (scrollLeft <= xThreshold) {
1668
- isLeftBoundary = true;
1669
- }
1670
- }
1671
- }
1672
- if (isRollY) {
1673
- const yThreshold = $xeTable.computeScrollYThreshold;
1674
- isTop = scrollTop <= 0;
1675
- if (!isTop) {
1676
- isBottom = scrollTop + bodyHeight >= scrollHeight - 1;
1677
- }
1678
- if (scrollTop > lastScrollTop) {
1679
- direction = 'bottom';
1680
- if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
1681
- isBottomBoundary = true;
1682
- }
1683
- }
1684
- else {
1685
- direction = 'top';
1686
- if (scrollTop <= yThreshold) {
1687
- isTopBoundary = true;
1688
- }
1689
- }
1690
- }
1691
- handleScrollData($xeGanttView, isRollY, isRollX, scrollTop, scrollLeft);
1692
- const evntParams = {
1693
- source: sourceType,
1694
- scrollTop,
1695
- scrollLeft,
1696
- bodyHeight,
1697
- bodyWidth,
1698
- scrollHeight,
1699
- scrollWidth,
1700
- isX: isRollX,
1701
- isY: isRollY,
1702
- isTop,
1703
- isBottom,
1704
- isLeft,
1705
- isRight,
1706
- direction
1707
- };
1708
- if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
1709
- $xeGantt.dispatchEvent('scroll-boundary', evntParams, evnt);
1710
- }
1711
- $xeGantt.dispatchEvent('scroll', evntParams, evnt);
1712
- }
1713
1641
  /**
1714
1642
  * 同步表格滚动
1715
1643
  */
@@ -1743,13 +1671,104 @@ export default defineVxeComponent({
1743
1671
  const xID = XEUtils.uniqueId();
1744
1672
  const reactData = createReactData();
1745
1673
  const internalData = createInternalData();
1674
+ const scrollDefaultConf = Object.assign({}, getConfig().scrollbar);
1746
1675
  return {
1747
1676
  xID,
1748
1677
  reactData,
1749
- internalData
1678
+ internalData,
1679
+ scrollDefaultConf,
1680
+ reScrollFlag: 0
1750
1681
  };
1751
1682
  },
1752
- computed: Object.assign(Object.assign({}, {}), { computeScaleDateList() {
1683
+ computed: Object.assign(Object.assign({}, {}), { computeScrollbarXOpts() {
1684
+ const $xeGanttView = this;
1685
+ const $xeGantt = $xeGanttView.$xeGantt;
1686
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1687
+ return scrollbarOpts.x ? Object.assign({}, scrollbarOpts.x, scrollbarOpts.xConfig) : (scrollbarOpts.xConfig || {});
1688
+ },
1689
+ computeScrollbarYOpts() {
1690
+ const $xeGanttView = this;
1691
+ const $xeGantt = $xeGanttView.$xeGantt;
1692
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1693
+ return scrollbarOpts.y ? Object.assign({}, scrollbarOpts.y, scrollbarOpts.yConfig) : (scrollbarOpts.yConfig || {});
1694
+ },
1695
+ computeScrollXHeight() {
1696
+ const $xeGanttView = this;
1697
+ const $xeGantt = $xeGanttView.$xeGantt;
1698
+ const scrollDefaultConf = $xeGanttView.scrollDefaultConf;
1699
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1700
+ const scrollbarXOpts = $xeGanttView.computeScrollbarXOpts;
1701
+ return XEUtils.toNumber(getDefaultConfig(getDefaultConfig(scrollbarXOpts.height, scrollbarOpts.height), scrollDefaultConf.height));
1702
+ },
1703
+ computeScrollYWidth() {
1704
+ const $xeGanttView = this;
1705
+ const $xeGantt = $xeGanttView.$xeGantt;
1706
+ const scrollDefaultConf = $xeGanttView.scrollDefaultConf;
1707
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1708
+ const scrollbarYOpts = $xeGanttView.computeScrollbarYOpts;
1709
+ return XEUtils.toNumber(getDefaultConfig(getDefaultConfig(scrollbarYOpts.width, scrollbarOpts.width), scrollDefaultConf.width));
1710
+ },
1711
+ computeScrollXVisible() {
1712
+ const $xeGanttView = this;
1713
+ const $xeGantt = $xeGanttView.$xeGantt;
1714
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1715
+ const scrollbarXOpts = $xeGanttView.computeScrollbarXOpts;
1716
+ return getDefaultConfig(scrollbarXOpts.visible, scrollbarOpts.visible);
1717
+ },
1718
+ computeScrollYVisible() {
1719
+ const $xeGanttView = this;
1720
+ const $xeGantt = $xeGanttView.$xeGantt;
1721
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1722
+ const scrollbarYOpts = $xeGanttView.computeScrollbarYOpts;
1723
+ return getDefaultConfig(scrollbarYOpts.visible, scrollbarOpts.visible);
1724
+ },
1725
+ computeScrollXAutoHide() {
1726
+ const $xeGanttView = this;
1727
+ const $xeGantt = $xeGanttView.$xeGantt;
1728
+ const scrollDefaultConf = $xeGanttView.scrollDefaultConf;
1729
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1730
+ const scrollbarXOpts = $xeGanttView.computeScrollbarXOpts;
1731
+ return getDefaultConfig(getDefaultConfig(scrollbarXOpts.autoHide, scrollbarOpts.autoHide), scrollDefaultConf.autoHide);
1732
+ },
1733
+ computeScrollYAutoHide() {
1734
+ const $xeGanttView = this;
1735
+ const $xeGantt = $xeGanttView.$xeGantt;
1736
+ const scrollDefaultConf = $xeGanttView.scrollDefaultConf;
1737
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
1738
+ const scrollbarYOpts = $xeGanttView.computeScrollbarYOpts;
1739
+ return getDefaultConfig(getDefaultConfig(scrollbarYOpts.autoHide, scrollbarOpts.autoHide), scrollDefaultConf.autoHide);
1740
+ },
1741
+ computeScrollbarXToTop() {
1742
+ const $xeGanttView = this;
1743
+ const scrollbarXOpts = $xeGanttView.computeScrollbarXOpts;
1744
+ return scrollbarXOpts.position === 'top';
1745
+ },
1746
+ computeScrollbarYToLeft() {
1747
+ const $xeGanttView = this;
1748
+ const scrollbarYOpts = $xeGanttView.computeScrollbarYOpts;
1749
+ return scrollbarYOpts.position === 'left';
1750
+ },
1751
+ computeScrollbarWrapperClss() {
1752
+ const $xeGanttView = this;
1753
+ const reactData = $xeGanttView.reactData;
1754
+ const $xeGantt = $xeGanttView.$xeGantt;
1755
+ const { yThumbHeight, xThumbWidth } = reactData;
1756
+ const scrollbarXToTop = $xeGantt.computeScrollbarXToTop;
1757
+ const scrollbarYToLeft = $xeGantt.computeScrollbarYToLeft;
1758
+ const scrollXVisible = $xeGanttView.computeScrollXVisible;
1759
+ const scrollYVisible = $xeGanttView.computeScrollYVisible;
1760
+ return domUtils.buildClass([
1761
+ 'vxe-scrollbar is--virtual',
1762
+ `ov-x--${scrollXVisible === false ? 'hidden' : 'visible'}`,
1763
+ `ov-y--${scrollYVisible === false ? 'hidden' : 'visible'}`,
1764
+ `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`,
1765
+ `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`
1766
+ ], {
1767
+ 'overflow-y': yThumbHeight,
1768
+ 'overflow-x': xThumbWidth
1769
+ });
1770
+ },
1771
+ computeScaleDateList() {
1753
1772
  const $xeGanttView = this;
1754
1773
  const $xeGantt = $xeGanttView.$xeGantt;
1755
1774
  const reactData = $xeGanttView.reactData;
@@ -1988,6 +2007,93 @@ export default defineVxeComponent({
1988
2007
  }
1989
2008
  }
1990
2009
  },
2010
+ handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft) {
2011
+ const $xeGanttView = this;
2012
+ const internalData = $xeGanttView.internalData;
2013
+ const $xeGantt = $xeGanttView.$xeGantt;
2014
+ const $xeTable = internalData.xeTable;
2015
+ const { elemStore, lastScrollLeft, lastScrollTop } = internalData;
2016
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
2017
+ if (!bodyScrollElem) {
2018
+ return;
2019
+ }
2020
+ if (!$xeTable) {
2021
+ return;
2022
+ }
2023
+ const bodyHeight = bodyScrollElem.clientHeight;
2024
+ const bodyWidth = bodyScrollElem.clientWidth;
2025
+ const scrollHeight = bodyScrollElem.scrollHeight;
2026
+ const scrollWidth = bodyScrollElem.scrollWidth;
2027
+ let isTop = false;
2028
+ let isBottom = false;
2029
+ let isLeft = false;
2030
+ let isRight = false;
2031
+ let direction = '';
2032
+ let isTopBoundary = false;
2033
+ let isBottomBoundary = false;
2034
+ let isLeftBoundary = false;
2035
+ let isRightBoundary = false;
2036
+ if (isRollX) {
2037
+ const xThreshold = $xeTable.computeScrollXThreshold;
2038
+ isLeft = scrollLeft <= 0;
2039
+ if (!isLeft) {
2040
+ isRight = scrollLeft + bodyWidth >= scrollWidth - 1;
2041
+ }
2042
+ if (scrollLeft > lastScrollLeft) {
2043
+ direction = 'right';
2044
+ if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
2045
+ isRightBoundary = true;
2046
+ }
2047
+ }
2048
+ else {
2049
+ direction = 'left';
2050
+ if (scrollLeft <= xThreshold) {
2051
+ isLeftBoundary = true;
2052
+ }
2053
+ }
2054
+ }
2055
+ if (isRollY) {
2056
+ const yThreshold = $xeTable.computeScrollYThreshold;
2057
+ isTop = scrollTop <= 0;
2058
+ if (!isTop) {
2059
+ isBottom = scrollTop + bodyHeight >= scrollHeight - 1;
2060
+ }
2061
+ if (scrollTop > lastScrollTop) {
2062
+ direction = 'bottom';
2063
+ if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
2064
+ isBottomBoundary = true;
2065
+ }
2066
+ }
2067
+ else {
2068
+ direction = 'top';
2069
+ if (scrollTop <= yThreshold) {
2070
+ isTopBoundary = true;
2071
+ }
2072
+ }
2073
+ }
2074
+ $xeGanttView.updateThumbOffset();
2075
+ handleScrollData($xeGanttView, isRollY, isRollX, scrollTop, scrollLeft);
2076
+ const evntParams = {
2077
+ source: sourceType,
2078
+ scrollTop,
2079
+ scrollLeft,
2080
+ bodyHeight,
2081
+ bodyWidth,
2082
+ scrollHeight,
2083
+ scrollWidth,
2084
+ isX: isRollX,
2085
+ isY: isRollY,
2086
+ isTop,
2087
+ isBottom,
2088
+ isLeft,
2089
+ isRight,
2090
+ direction
2091
+ };
2092
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
2093
+ $xeGantt.dispatchEvent('scroll-boundary', evntParams, evnt);
2094
+ }
2095
+ $xeGantt.dispatchEvent('scroll', evntParams, evnt);
2096
+ },
1991
2097
  triggerHeaderScrollEvent(evnt) {
1992
2098
  const $xeGanttView = this;
1993
2099
  const internalData = $xeGanttView.internalData;
@@ -2008,7 +2114,7 @@ export default defineVxeComponent({
2008
2114
  internalData.inHeaderScroll = true;
2009
2115
  setScrollLeft(xHandleEl, currLeftNum);
2010
2116
  setScrollLeft(bodyScrollElem, currLeftNum);
2011
- handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
2117
+ $xeGanttView.handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
2012
2118
  }
2013
2119
  },
2014
2120
  triggerBodyScrollEvent(evnt) {
@@ -2045,7 +2151,7 @@ export default defineVxeComponent({
2045
2151
  triggerScrollXEvent($xeGanttView);
2046
2152
  }
2047
2153
  }
2048
- handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, scrollLeft);
2154
+ $xeGanttView.handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, scrollLeft);
2049
2155
  },
2050
2156
  // triggerFooterScrollEvent (evnt: Event) {
2051
2157
  // const $xeGanttView = this
@@ -2062,7 +2168,7 @@ export default defineVxeComponent({
2062
2168
  // const isRollX = true
2063
2169
  // const isRollY = false
2064
2170
  // const currLeftNum = wrapperEl.scrollLeft
2065
- // handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum)
2171
+ // $xeGanttView.handleScrollEvent(, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum)
2066
2172
  // }
2067
2173
  // },
2068
2174
  triggerVirtualScrollXEvent(evnt) {
@@ -2087,7 +2193,7 @@ export default defineVxeComponent({
2087
2193
  if (scrollXLoad) {
2088
2194
  triggerScrollXEvent($xeGanttView);
2089
2195
  }
2090
- handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
2196
+ $xeGanttView.handleScrollEvent(evnt, isRollY, isRollX, wrapperEl.scrollTop, currLeftNum);
2091
2197
  }
2092
2198
  },
2093
2199
  triggerVirtualScrollYEvent(evnt) {
@@ -2106,7 +2212,7 @@ export default defineVxeComponent({
2106
2212
  internalData.inVirtualScroll = true;
2107
2213
  setScrollTop(bodyScrollElem, currTopNum);
2108
2214
  syncTableScrollTop($xeGanttView, currTopNum);
2109
- handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, currTopNum, wrapperEl.scrollLeft);
2215
+ $xeGanttView.handleScrollEvent(evnt, isRollY, isRollX, currTopNum, wrapperEl.scrollLeft);
2110
2216
  }
2111
2217
  },
2112
2218
  handleUpdateSXSpace() {
@@ -2122,10 +2228,207 @@ export default defineVxeComponent({
2122
2228
  const reactData = $xeGanttView.reactData;
2123
2229
  reactData.scrollYLoad = sYLoad;
2124
2230
  },
2231
+ /**
2232
+ * @private
2233
+ */
2234
+ updateScrollbar() {
2235
+ const $xeGanttView = this;
2236
+ $xeGanttView.updateThumbSize();
2237
+ $xeGanttView.updateThumbOffset();
2238
+ },
2125
2239
  handleGlobalResizeEvent() {
2126
2240
  const $xeGanttView = this;
2127
2241
  handleLazyRecalculate($xeGanttView);
2128
2242
  },
2243
+ // 滚动条
2244
+ updateThumbSize() {
2245
+ const $xeGanttView = this;
2246
+ const reactData = $xeGanttView.reactData;
2247
+ const internalData = $xeGanttView.internalData;
2248
+ const { elemStore } = internalData;
2249
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2250
+ if (!viewEl) {
2251
+ return;
2252
+ }
2253
+ if (!viewEl.clientHeight || !viewEl.clientHeight) {
2254
+ return;
2255
+ }
2256
+ const trackXEl = $xeGanttView.$refs.refTrackXElem;
2257
+ const xThumbWidth = trackXEl ? getThumbSize(viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth) : 0;
2258
+ const thumbXElem = $xeGanttView.$refs.refThumbXElem;
2259
+ if (thumbXElem) {
2260
+ thumbXElem.style.width = xThumbWidth + 'px';
2261
+ }
2262
+ reactData.xThumbWidth = xThumbWidth;
2263
+ const trackYEl = $xeGanttView.$refs.refTrackYElem;
2264
+ const yThumbHeight = trackYEl ? getThumbSize(viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight) : 0;
2265
+ const thumbYElem = $xeGanttView.$refs.refThumbYElem;
2266
+ if (thumbYElem) {
2267
+ thumbYElem.style.height = yThumbHeight + 'px';
2268
+ }
2269
+ reactData.yThumbHeight = yThumbHeight;
2270
+ },
2271
+ updateThumbOffset() {
2272
+ const $xeGanttView = this;
2273
+ const reactData = $xeGanttView.reactData;
2274
+ const internalData = $xeGanttView.internalData;
2275
+ const { elemStore } = internalData;
2276
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2277
+ if (!viewEl) {
2278
+ return;
2279
+ }
2280
+ if (!viewEl.clientHeight || !viewEl.clientHeight) {
2281
+ return;
2282
+ }
2283
+ const { xThumbWidth, yThumbHeight } = reactData;
2284
+ const trackXEl = $xeGanttView.$refs.refTrackXElem;
2285
+ const thumbXElem = $xeGanttView.$refs.refThumbXElem;
2286
+ const xThumbLeft = trackXEl && xThumbWidth ? getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth, xThumbWidth) : 0;
2287
+ internalData.xThumbLeft = xThumbLeft;
2288
+ if (thumbXElem && xThumbWidth) {
2289
+ thumbXElem.style.width = xThumbWidth + 'px';
2290
+ thumbXElem.style.transform = `translateX(${xThumbLeft}px)`;
2291
+ }
2292
+ const trackYEl = $xeGanttView.$refs.refTrackYElem;
2293
+ const thumbYElem = $xeGanttView.$refs.refThumbYElem;
2294
+ const yThumbTop = trackYEl && yThumbHeight ? getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight, yThumbHeight) : 0;
2295
+ internalData.yThumbTop = yThumbTop;
2296
+ if (thumbYElem && yThumbHeight) {
2297
+ thumbYElem.style.height = yThumbHeight + 'px';
2298
+ thumbYElem.style.transform = `translateY(${yThumbTop}px)`;
2299
+ }
2300
+ },
2301
+ clickTrackXEvent(evnt) {
2302
+ const $xeGanttView = this;
2303
+ const reactData = $xeGanttView.reactData;
2304
+ const internalData = $xeGanttView.internalData;
2305
+ const trackEl = evnt.currentTarget;
2306
+ if (trackEl !== evnt.target) {
2307
+ return;
2308
+ }
2309
+ const { elemStore } = internalData;
2310
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2311
+ if (!viewEl) {
2312
+ return;
2313
+ }
2314
+ const { xThumbWidth } = reactData;
2315
+ const trackRect = trackEl.getBoundingClientRect();
2316
+ viewEl.scrollTo({
2317
+ left: getScrollFromClick(evnt.clientX - trackRect.left, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth),
2318
+ behavior: 'auto'
2319
+ });
2320
+ },
2321
+ clickTrackYEvent(evnt) {
2322
+ const $xeGanttView = this;
2323
+ const reactData = $xeGanttView.reactData;
2324
+ const internalData = $xeGanttView.internalData;
2325
+ const trackEl = evnt.currentTarget;
2326
+ if (trackEl !== evnt.target) {
2327
+ return;
2328
+ }
2329
+ const { elemStore } = internalData;
2330
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2331
+ if (!viewEl) {
2332
+ return;
2333
+ }
2334
+ const { yThumbHeight } = reactData;
2335
+ const trackRect = trackEl.getBoundingClientRect();
2336
+ viewEl.scrollTo({
2337
+ top: getScrollFromClick(evnt.clientY - trackRect.top, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight),
2338
+ behavior: 'auto'
2339
+ });
2340
+ },
2341
+ pointerdownThumbXEvent(evnt) {
2342
+ const $xeGanttView = this;
2343
+ const reactData = $xeGanttView.reactData;
2344
+ const internalData = $xeGanttView.internalData;
2345
+ const thumbEl = evnt.currentTarget;
2346
+ internalData.isThumbDrag = true;
2347
+ thumbEl.setPointerCapture(evnt.pointerId);
2348
+ const { elemStore } = internalData;
2349
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2350
+ if (!viewEl) {
2351
+ return;
2352
+ }
2353
+ const { xThumbWidth } = reactData;
2354
+ const trackEl = thumbEl.parentElement;
2355
+ const trackRect = trackEl.getBoundingClientRect();
2356
+ const pointerPosition = evnt.clientX - trackRect.left;
2357
+ // 记录 thumb 的偏移
2358
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
2359
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
2360
+ },
2361
+ pointermoveThumbXEvent(evnt) {
2362
+ const $xeGanttView = this;
2363
+ const reactData = $xeGanttView.reactData;
2364
+ const internalData = $xeGanttView.internalData;
2365
+ const thumbEl = evnt.currentTarget;
2366
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
2367
+ return;
2368
+ }
2369
+ const { elemStore, isThumbDrag, thumbDragOffset } = internalData;
2370
+ if (isThumbDrag) {
2371
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2372
+ if (!viewEl) {
2373
+ return;
2374
+ }
2375
+ const { xThumbWidth } = reactData;
2376
+ const thumbEl = evnt.currentTarget;
2377
+ const trackEl = thumbEl.parentElement;
2378
+ const trackRect = trackEl.getBoundingClientRect();
2379
+ // 更新偏移
2380
+ viewEl.scrollLeft = getScrollFromDrag(evnt.clientX - trackRect.left, thumbDragOffset, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth);
2381
+ }
2382
+ },
2383
+ cleatPointerThumbEvent(evnt) {
2384
+ const $xeGanttView = this;
2385
+ const internalData = $xeGanttView.internalData;
2386
+ const thumbEl = evnt.currentTarget;
2387
+ thumbEl.releasePointerCapture(evnt.pointerId);
2388
+ internalData.isThumbDrag = false;
2389
+ },
2390
+ pointerdownThumbYEvent(evnt) {
2391
+ const $xeGanttView = this;
2392
+ const reactData = $xeGanttView.reactData;
2393
+ const internalData = $xeGanttView.internalData;
2394
+ const thumbEl = evnt.currentTarget;
2395
+ internalData.isThumbDrag = true;
2396
+ thumbEl.setPointerCapture(evnt.pointerId);
2397
+ const { elemStore } = internalData;
2398
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2399
+ if (!viewEl) {
2400
+ return;
2401
+ }
2402
+ const { yThumbHeight } = reactData;
2403
+ const trackEl = thumbEl.parentElement;
2404
+ const trackRect = trackEl.getBoundingClientRect();
2405
+ const pointerPosition = evnt.clientY - trackRect.top;
2406
+ // 记录 thumb 的偏移
2407
+ const thumbOffset = getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
2408
+ internalData.thumbDragOffset = pointerPosition - thumbOffset;
2409
+ },
2410
+ pointermoveThumbYEvent(evnt) {
2411
+ const $xeGanttView = this;
2412
+ const reactData = $xeGanttView.reactData;
2413
+ const internalData = $xeGanttView.internalData;
2414
+ const thumbEl = evnt.currentTarget;
2415
+ if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
2416
+ return;
2417
+ }
2418
+ const { elemStore, isThumbDrag, thumbDragOffset } = internalData;
2419
+ if (isThumbDrag) {
2420
+ const viewEl = getRefElem(elemStore['main-body-scroll']);
2421
+ if (!viewEl) {
2422
+ return;
2423
+ }
2424
+ const { yThumbHeight } = reactData;
2425
+ const thumbEl = evnt.currentTarget;
2426
+ const trackEl = thumbEl.parentElement;
2427
+ const trackRect = trackEl.getBoundingClientRect();
2428
+ // 更新偏移
2429
+ viewEl.scrollTop = getScrollFromDrag(evnt.clientY - trackRect.top, thumbDragOffset, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight);
2430
+ }
2431
+ },
2129
2432
  //
2130
2433
  // Render
2131
2434
  //
@@ -2211,7 +2514,7 @@ export default defineVxeComponent({
2211
2514
  h(GanttViewFooterComponent)
2212
2515
  ]);
2213
2516
  },
2214
- renderBody(h) {
2517
+ renderNativeBody(h) {
2215
2518
  const $xeGanttView = this;
2216
2519
  const $xeGantt = $xeGanttView.$xeGantt;
2217
2520
  const scrollbarYToLeft = $xeGantt.computeScrollbarYToLeft;
@@ -2227,10 +2530,89 @@ export default defineVxeComponent({
2227
2530
  $xeGanttView.renderScrollY(h)
2228
2531
  ]);
2229
2532
  },
2533
+ renderVirtualBody(h) {
2534
+ const $xeGanttView = this;
2535
+ const $xeGantt = $xeGanttView.$xeGantt;
2536
+ const reactData = $xeGanttView.reactData;
2537
+ const ganttReactData = $xeGantt.reactData;
2538
+ const ganttProps = $xeGantt;
2539
+ const { showLeftView } = ganttReactData;
2540
+ const { useScrollbar } = ganttProps;
2541
+ const { xThumbWidth, yThumbHeight } = reactData;
2542
+ const scrollbarOpts = $xeGantt.computeScrollbarOpts;
2543
+ const scrollXAutoHide = $xeGanttView.computeScrollXAutoHide;
2544
+ const scrollYAutoHide = $xeGanttView.computeScrollYAutoHide;
2545
+ const scrollXVisible = $xeGanttView.computeScrollXVisible;
2546
+ const scrollYVisible = $xeGanttView.computeScrollYVisible;
2547
+ const scrollbarXToTop = $xeGanttView.computeScrollbarXToTop;
2548
+ const scrollbarYToLeft = $xeGantt.computeScrollbarYToLeft;
2549
+ const scrollbarWrapperClss = $xeGanttView.computeScrollbarWrapperClss;
2550
+ return h('div', {
2551
+ key: 'lvb',
2552
+ class: ['vxe-gantt--layout-wrapper', `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
2553
+ 'is--virtual-scrollbar': useScrollbar,
2554
+ 'ov-padding': useScrollbar && scrollbarOpts.padding,
2555
+ 'ov-x--auto-hide': useScrollbar && scrollXAutoHide,
2556
+ 'ov-y--auto-hide': useScrollbar && scrollYAutoHide,
2557
+ 'overflow-y': yThumbHeight,
2558
+ 'overflow-x': xThumbWidth
2559
+ }]
2560
+ }, [
2561
+ $xeGanttView.renderViewport(h),
2562
+ h('div', {
2563
+ class: scrollbarWrapperClss
2564
+ }, [
2565
+ scrollXVisible === false
2566
+ ? renderEmptyElement($xeGantt)
2567
+ : h('div', {
2568
+ ref: 'refTrackXElem',
2569
+ class: 'vxe-scrollbar--track-x',
2570
+ on: {
2571
+ click: $xeGanttView.clickTrackXEvent
2572
+ }
2573
+ }, [
2574
+ h('div', {
2575
+ ref: 'refThumbXElem',
2576
+ class: 'vxe-scrollbar--thumb-x',
2577
+ on: {
2578
+ pointerdown: $xeGanttView.pointerdownThumbXEvent,
2579
+ pointermove: $xeGanttView.pointermoveThumbXEvent,
2580
+ pointerup: $xeGanttView.cleatPointerThumbEvent,
2581
+ pointercancel: $xeGanttView.cleatPointerThumbEvent,
2582
+ lostpointercapture: $xeGanttView.cleatPointerThumbEvent
2583
+ }
2584
+ })
2585
+ ]),
2586
+ (scrollbarYToLeft && showLeftView) || scrollYVisible === false
2587
+ ? renderEmptyElement($xeGantt)
2588
+ : h('div', {
2589
+ ref: 'refTrackYElem',
2590
+ class: 'vxe-scrollbar--track-y',
2591
+ on: {
2592
+ click: $xeGanttView.clickTrackYEvent
2593
+ }
2594
+ }, [
2595
+ h('div', {
2596
+ ref: 'refThumbYElem',
2597
+ class: 'vxe-scrollbar--thumb-y',
2598
+ on: {
2599
+ pointerdown: $xeGanttView.pointerdownThumbYEvent,
2600
+ pointermove: $xeGanttView.pointermoveThumbYEvent,
2601
+ pointerup: $xeGanttView.cleatPointerThumbEvent,
2602
+ pointercancel: $xeGanttView.cleatPointerThumbEvent,
2603
+ lostpointercapture: $xeGanttView.cleatPointerThumbEvent
2604
+ }
2605
+ })
2606
+ ])
2607
+ ])
2608
+ ]);
2609
+ },
2230
2610
  renderVN(h) {
2231
2611
  const $xeGanttView = this;
2232
2612
  const $xeGantt = $xeGanttView.$xeGantt;
2233
2613
  const reactData = $xeGanttView.reactData;
2614
+ const ganttProps = $xeGantt;
2615
+ const { useScrollbar } = ganttProps;
2234
2616
  const { overflowX, overflowY, scrollXLoad, scrollYLoad } = reactData;
2235
2617
  const scrollbarXToTop = $xeGantt.computeScrollbarXToTop;
2236
2618
  return h('div', {
@@ -2244,15 +2626,17 @@ export default defineVxeComponent({
2244
2626
  }, [
2245
2627
  h('div', {
2246
2628
  class: 'vxe-gantt-view--render-wrapper'
2247
- }, scrollbarXToTop
2248
- ? [
2249
- $xeGanttView.renderScrollX(h),
2250
- $xeGanttView.renderBody(h)
2251
- ]
2252
- : [
2253
- $xeGanttView.renderBody(h),
2254
- $xeGanttView.renderScrollX(h)
2255
- ]),
2629
+ }, useScrollbar
2630
+ ? [$xeGanttView.renderVirtualBody(h)]
2631
+ : (scrollbarXToTop
2632
+ ? [
2633
+ $xeGanttView.renderScrollX(h),
2634
+ $xeGanttView.renderNativeBody(h)
2635
+ ]
2636
+ : [
2637
+ $xeGanttView.renderNativeBody(h),
2638
+ $xeGanttView.renderScrollX(h)
2639
+ ])),
2256
2640
  h('div', {
2257
2641
  class: 'vxe-gantt-view--render-vars'
2258
2642
  }, [
@@ -2264,14 +2648,74 @@ export default defineVxeComponent({
2264
2648
  ]);
2265
2649
  }
2266
2650
  },
2651
+ watch: {
2652
+ computeScrollbarXToTop() {
2653
+ const $xeGanttView = this;
2654
+ $xeGanttView.reScrollFlag++;
2655
+ },
2656
+ computeScrollbarYToLeft() {
2657
+ const $xeGanttView = this;
2658
+ $xeGanttView.reScrollFlag++;
2659
+ },
2660
+ computeScrollXVisible() {
2661
+ const $xeGanttView = this;
2662
+ $xeGanttView.reScrollFlag++;
2663
+ },
2664
+ computeScrollYVisible() {
2665
+ const $xeGanttView = this;
2666
+ $xeGanttView.reScrollFlag++;
2667
+ },
2668
+ computeScrollXHeight() {
2669
+ const $xeGanttView = this;
2670
+ $xeGanttView.reScrollFlag++;
2671
+ },
2672
+ computeScrollYWidth() {
2673
+ const $xeGanttView = this;
2674
+ $xeGanttView.reScrollFlag++;
2675
+ },
2676
+ reScrollFlag() {
2677
+ const $xeGanttView = this;
2678
+ $xeGanttView.$nextTick(() => {
2679
+ $xeGanttView.updateScrollbar();
2680
+ $xeGanttView.$nextTick(() => {
2681
+ $xeGanttView.updateScrollbar();
2682
+ });
2683
+ });
2684
+ }
2685
+ },
2267
2686
  mounted() {
2268
2687
  const $xeGanttView = this;
2688
+ const $xeGantt = $xeGanttView.$xeGantt;
2689
+ const internalData = $xeGanttView.internalData;
2690
+ $xeGanttView.$nextTick(() => {
2691
+ const ganttProps = $xeGantt;
2692
+ const { useScrollbar } = ganttProps;
2693
+ const { elemStore } = internalData;
2694
+ const el = $xeGanttView.$refs.refElem;
2695
+ if (useScrollbar) {
2696
+ const viewInnerEl = getRefElem(elemStore['main-body-table']);
2697
+ const scrollObserver = globalResize.create(() => {
2698
+ $xeGanttView.reScrollFlag++;
2699
+ });
2700
+ if (el) {
2701
+ scrollObserver.observe(el);
2702
+ }
2703
+ if (viewInnerEl) {
2704
+ scrollObserver.observe(viewInnerEl);
2705
+ }
2706
+ internalData.scrollObserver = scrollObserver;
2707
+ }
2708
+ });
2269
2709
  globalEvents.on($xeGanttView, 'resize', $xeGanttView.handleGlobalResizeEvent);
2270
2710
  },
2271
2711
  beforeDestroy() {
2272
2712
  const $xeGanttView = this;
2273
2713
  const reactData = $xeGanttView.reactData;
2274
2714
  const internalData = $xeGanttView.internalData;
2715
+ const { scrollObserver } = internalData;
2716
+ if (scrollObserver) {
2717
+ scrollObserver.disconnect();
2718
+ }
2275
2719
  globalEvents.off($xeGanttView, 'keydown');
2276
2720
  XEUtils.assign(reactData, createReactData());
2277
2721
  XEUtils.assign(internalData, createInternalData());