gantt-task-react-v 1.2.14 → 1.3.2
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.
- package/dist/gantt-task-react.es.js +383 -50
- package/dist/gantt-task-react.umd.js +383 -50
- package/dist/helpers/use-incremental-coordinates.d.ts +17 -0
- package/dist/helpers/use-memory-management.d.ts +122 -0
- package/dist/helpers/use-optimized-data-structures.d.ts +24 -0
- package/dist/helpers/use-optimized-svg-rendering.d.ts +117 -0
- package/dist/helpers/use-performance-monitor.d.ts +106 -0
- package/dist/helpers/use-progressive-loading.d.ts +63 -0
- package/dist/helpers/use-spatial-dependency-map.d.ts +49 -0
- package/dist/helpers/use-web-worker.d.ts +50 -0
- package/package.json +7 -5
|
@@ -4684,11 +4684,14 @@ const getStartAndEnd = (containerEl, property, cellSize) => {
|
|
|
4684
4684
|
if (!containerEl) {
|
|
4685
4685
|
return null;
|
|
4686
4686
|
}
|
|
4687
|
-
const
|
|
4688
|
-
const
|
|
4689
|
-
const
|
|
4690
|
-
const
|
|
4691
|
-
const
|
|
4687
|
+
const el = containerEl;
|
|
4688
|
+
const scrollValue = property === "scrollLeft" ? el.scrollLeft : el.scrollTop;
|
|
4689
|
+
const maxScrollValue = property === "scrollLeft" ? el.scrollWidth : el.scrollHeight;
|
|
4690
|
+
const fullValue = property === "scrollLeft" ? el.clientWidth : el.clientHeight;
|
|
4691
|
+
const firstIndex = Math.max(0, Math.floor(scrollValue / cellSize));
|
|
4692
|
+
const visibleCount = Math.max(1, Math.ceil(fullValue / cellSize));
|
|
4693
|
+
const overscan = Math.min(100, Math.max(10, Math.ceil(visibleCount * 0.5)));
|
|
4694
|
+
const lastIndex = Math.floor((scrollValue + fullValue) / cellSize) + overscan;
|
|
4692
4695
|
const isStartOfScroll = scrollValue < DELTA;
|
|
4693
4696
|
const isEndOfScroll = scrollValue + fullValue > maxScrollValue - DELTA;
|
|
4694
4697
|
return [firstIndex, lastIndex, isStartOfScroll, isEndOfScroll, fullValue];
|
|
@@ -4697,31 +4700,49 @@ const useOptimizedList = (containerRef, property, cellSize) => {
|
|
|
4697
4700
|
const [indexes, setIndexes] = useState(
|
|
4698
4701
|
() => getStartAndEnd(containerRef.current, property, cellSize)
|
|
4699
4702
|
);
|
|
4703
|
+
const rafRef = useRef(null);
|
|
4704
|
+
const pendingRef = useRef(false);
|
|
4705
|
+
const update = useMemo(() => {
|
|
4706
|
+
const fn = () => {
|
|
4707
|
+
pendingRef.current = false;
|
|
4708
|
+
const next = getStartAndEnd(containerRef.current, property, cellSize);
|
|
4709
|
+
setIndexes((prev) => {
|
|
4710
|
+
const changed = !prev || !next || next.some((v, i) => prev ? prev[i] !== v : true);
|
|
4711
|
+
return changed ? next : prev;
|
|
4712
|
+
});
|
|
4713
|
+
rafRef.current = null;
|
|
4714
|
+
};
|
|
4715
|
+
return fn;
|
|
4716
|
+
}, [cellSize, containerRef, property]);
|
|
4700
4717
|
useEffect(() => {
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
) : true : Boolean(nextIndexes);
|
|
4712
|
-
if (isChanged) {
|
|
4713
|
-
prevIndexes = nextIndexes;
|
|
4714
|
-
setIndexes(nextIndexes);
|
|
4715
|
-
}
|
|
4716
|
-
rafId = requestAnimationFrame(handler);
|
|
4718
|
+
const el = containerRef.current;
|
|
4719
|
+
if (!el) {
|
|
4720
|
+
return void 0;
|
|
4721
|
+
}
|
|
4722
|
+
setIndexes(getStartAndEnd(el, property, cellSize));
|
|
4723
|
+
const onScroll = () => {
|
|
4724
|
+
if (pendingRef.current)
|
|
4725
|
+
return;
|
|
4726
|
+
pendingRef.current = true;
|
|
4727
|
+
rafRef.current = requestAnimationFrame(update);
|
|
4717
4728
|
};
|
|
4718
|
-
|
|
4729
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
4730
|
+
if (pendingRef.current)
|
|
4731
|
+
return;
|
|
4732
|
+
pendingRef.current = true;
|
|
4733
|
+
rafRef.current = requestAnimationFrame(update);
|
|
4734
|
+
});
|
|
4735
|
+
resizeObserver.observe(el);
|
|
4736
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
4719
4737
|
return () => {
|
|
4720
|
-
|
|
4721
|
-
|
|
4738
|
+
el.removeEventListener("scroll", onScroll);
|
|
4739
|
+
resizeObserver.disconnect();
|
|
4740
|
+
if (rafRef.current !== null) {
|
|
4741
|
+
cancelAnimationFrame(rafRef.current);
|
|
4722
4742
|
}
|
|
4743
|
+
pendingRef.current = false;
|
|
4723
4744
|
};
|
|
4724
|
-
}, [cellSize, containerRef,
|
|
4745
|
+
}, [cellSize, containerRef, property, update]);
|
|
4725
4746
|
return indexes;
|
|
4726
4747
|
};
|
|
4727
4748
|
const taskListNameWrapper = "_taskListNameWrapper_16z6n_1";
|
|
@@ -10911,7 +10932,7 @@ const styles$c = {
|
|
|
10911
10932
|
};
|
|
10912
10933
|
const GanttTodayInner = ({
|
|
10913
10934
|
additionalLeftSpace,
|
|
10914
|
-
distances,
|
|
10935
|
+
distances: { columnWidth },
|
|
10915
10936
|
ganttFullHeight,
|
|
10916
10937
|
isUnknownDates,
|
|
10917
10938
|
rtl,
|
|
@@ -10925,7 +10946,6 @@ const GanttTodayInner = ({
|
|
|
10925
10946
|
todayLabel = "Today",
|
|
10926
10947
|
dataDateLabel = "Data Date"
|
|
10927
10948
|
}) => {
|
|
10928
|
-
const { columnWidth, rowHeight, barFill } = distances;
|
|
10929
10949
|
const todayElement = useMemo(() => {
|
|
10930
10950
|
if (isUnknownDates || !showTodayLine) {
|
|
10931
10951
|
return null;
|
|
@@ -11032,20 +11052,13 @@ const GanttTodayInner = ({
|
|
|
11032
11052
|
}
|
|
11033
11053
|
};
|
|
11034
11054
|
const tickX = dataIndex * columnWidth * extraMultiplier();
|
|
11035
|
-
const
|
|
11055
|
+
const x = rtl ? tickX + columnWidth : tickX;
|
|
11036
11056
|
const color = dataDateColor || "var(--gantt-calendar-today-color)";
|
|
11037
|
-
const taskHeight = rowHeight * barFill / 100;
|
|
11038
|
-
const rotatedHeight = taskHeight / Math.SQRT2;
|
|
11039
|
-
const centerX = dateBaseX;
|
|
11040
|
-
const centerY = 6;
|
|
11041
|
-
const rectX = centerX - rotatedHeight / 2;
|
|
11042
|
-
const rectY = centerY - rotatedHeight / 2;
|
|
11043
|
-
const rightEdgeX = centerX + taskHeight / 2;
|
|
11044
11057
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11045
11058
|
/* @__PURE__ */ jsx(
|
|
11046
11059
|
"rect",
|
|
11047
11060
|
{
|
|
11048
|
-
x: additionalLeftSpace +
|
|
11061
|
+
x: additionalLeftSpace + x,
|
|
11049
11062
|
y: 0,
|
|
11050
11063
|
width: 2,
|
|
11051
11064
|
height: ganttFullHeight,
|
|
@@ -11054,22 +11067,19 @@ const GanttTodayInner = ({
|
|
|
11054
11067
|
}
|
|
11055
11068
|
),
|
|
11056
11069
|
/* @__PURE__ */ jsx(
|
|
11057
|
-
"
|
|
11070
|
+
"circle",
|
|
11058
11071
|
{
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
fill: color
|
|
11064
|
-
transform: `rotate(45 ${additionalLeftSpace + centerX} ${centerY})`,
|
|
11065
|
-
rx: 2,
|
|
11066
|
-
ry: 2
|
|
11072
|
+
className: styles$c.ganttTodayCircle,
|
|
11073
|
+
cx: x + 1,
|
|
11074
|
+
cy: 6,
|
|
11075
|
+
r: 6,
|
|
11076
|
+
fill: color
|
|
11067
11077
|
}
|
|
11068
11078
|
),
|
|
11069
11079
|
/* @__PURE__ */ jsx(
|
|
11070
11080
|
"text",
|
|
11071
11081
|
{
|
|
11072
|
-
x: additionalLeftSpace +
|
|
11082
|
+
x: additionalLeftSpace + x + 8,
|
|
11073
11083
|
y: 10,
|
|
11074
11084
|
fill: color,
|
|
11075
11085
|
fontSize: 12,
|
|
@@ -11088,9 +11098,7 @@ const GanttTodayInner = ({
|
|
|
11088
11098
|
showDataDateLine,
|
|
11089
11099
|
dataDate,
|
|
11090
11100
|
dataDateColor,
|
|
11091
|
-
dataDateLabel
|
|
11092
|
-
rowHeight,
|
|
11093
|
-
barFill
|
|
11101
|
+
dataDateLabel
|
|
11094
11102
|
]);
|
|
11095
11103
|
return /* @__PURE__ */ jsxs("g", { className: "today", children: [
|
|
11096
11104
|
dataDateElement,
|
|
@@ -17478,6 +17486,308 @@ const useHorizontalScrollbars = () => {
|
|
|
17478
17486
|
scrollToRightStep
|
|
17479
17487
|
];
|
|
17480
17488
|
};
|
|
17489
|
+
const usePerformanceMonitor = (enabled = true) => {
|
|
17490
|
+
const metricsRef = useRef([]);
|
|
17491
|
+
const benchmarksRef = useRef(/* @__PURE__ */ new Map());
|
|
17492
|
+
const frameTimesRef = useRef([]);
|
|
17493
|
+
const lastFrameTimeRef = useRef(performance.now());
|
|
17494
|
+
const updateFPS = useCallback(() => {
|
|
17495
|
+
if (!enabled)
|
|
17496
|
+
return;
|
|
17497
|
+
const now = performance.now();
|
|
17498
|
+
const deltaTime = now - lastFrameTimeRef.current;
|
|
17499
|
+
lastFrameTimeRef.current = now;
|
|
17500
|
+
frameTimesRef.current.push(deltaTime);
|
|
17501
|
+
if (frameTimesRef.current.length > 60) {
|
|
17502
|
+
frameTimesRef.current.shift();
|
|
17503
|
+
}
|
|
17504
|
+
}, [enabled]);
|
|
17505
|
+
const getFPS = useCallback(() => {
|
|
17506
|
+
if (frameTimesRef.current.length === 0)
|
|
17507
|
+
return 0;
|
|
17508
|
+
const avgFrameTime = frameTimesRef.current.reduce((sum, time) => sum + time, 0) / frameTimesRef.current.length;
|
|
17509
|
+
return Math.round(1e3 / avgFrameTime);
|
|
17510
|
+
}, []);
|
|
17511
|
+
const startMeasurement = useCallback(
|
|
17512
|
+
(name, metadata) => {
|
|
17513
|
+
if (!enabled)
|
|
17514
|
+
return;
|
|
17515
|
+
performance.mark(`${name}-start`);
|
|
17516
|
+
benchmarksRef.current.set(name, {
|
|
17517
|
+
name,
|
|
17518
|
+
startTime: performance.now(),
|
|
17519
|
+
metadata
|
|
17520
|
+
});
|
|
17521
|
+
},
|
|
17522
|
+
[enabled]
|
|
17523
|
+
);
|
|
17524
|
+
const endMeasurement = useCallback(
|
|
17525
|
+
(name) => {
|
|
17526
|
+
if (!enabled)
|
|
17527
|
+
return 0;
|
|
17528
|
+
const benchmark = benchmarksRef.current.get(name);
|
|
17529
|
+
if (!benchmark) {
|
|
17530
|
+
console.warn(`No benchmark found for ${name}`);
|
|
17531
|
+
return 0;
|
|
17532
|
+
}
|
|
17533
|
+
const endTime = performance.now();
|
|
17534
|
+
const duration = endTime - benchmark.startTime;
|
|
17535
|
+
performance.mark(`${name}-end`);
|
|
17536
|
+
performance.measure(name, `${name}-start`, `${name}-end`);
|
|
17537
|
+
benchmark.endTime = endTime;
|
|
17538
|
+
benchmark.duration = duration;
|
|
17539
|
+
return duration;
|
|
17540
|
+
},
|
|
17541
|
+
[enabled]
|
|
17542
|
+
);
|
|
17543
|
+
const measureFunction = useCallback(
|
|
17544
|
+
(name, fn, metadata) => {
|
|
17545
|
+
return (...args) => {
|
|
17546
|
+
if (!enabled)
|
|
17547
|
+
return fn(...args);
|
|
17548
|
+
startMeasurement(name, metadata);
|
|
17549
|
+
try {
|
|
17550
|
+
const result = fn(...args);
|
|
17551
|
+
return result;
|
|
17552
|
+
} finally {
|
|
17553
|
+
endMeasurement(name);
|
|
17554
|
+
}
|
|
17555
|
+
};
|
|
17556
|
+
},
|
|
17557
|
+
[enabled, startMeasurement, endMeasurement]
|
|
17558
|
+
);
|
|
17559
|
+
const measureAsyncFunction = useCallback(
|
|
17560
|
+
(name, fn, metadata) => {
|
|
17561
|
+
return async (...args) => {
|
|
17562
|
+
if (!enabled)
|
|
17563
|
+
return fn(...args);
|
|
17564
|
+
startMeasurement(name, metadata);
|
|
17565
|
+
try {
|
|
17566
|
+
const result = await fn(...args);
|
|
17567
|
+
return result;
|
|
17568
|
+
} finally {
|
|
17569
|
+
endMeasurement(name);
|
|
17570
|
+
}
|
|
17571
|
+
};
|
|
17572
|
+
},
|
|
17573
|
+
[enabled, startMeasurement, endMeasurement]
|
|
17574
|
+
);
|
|
17575
|
+
const getPerformanceReport = useCallback(() => {
|
|
17576
|
+
const entries = performance.getEntriesByType(
|
|
17577
|
+
"measure"
|
|
17578
|
+
);
|
|
17579
|
+
const report = {};
|
|
17580
|
+
entries.forEach((entry) => {
|
|
17581
|
+
if (!report[entry.name]) {
|
|
17582
|
+
report[entry.name] = {
|
|
17583
|
+
count: 0,
|
|
17584
|
+
totalTime: 0,
|
|
17585
|
+
avgTime: 0,
|
|
17586
|
+
maxTime: 0,
|
|
17587
|
+
minTime: Infinity
|
|
17588
|
+
};
|
|
17589
|
+
}
|
|
17590
|
+
const stat = report[entry.name];
|
|
17591
|
+
stat.count++;
|
|
17592
|
+
stat.totalTime += entry.duration;
|
|
17593
|
+
stat.maxTime = Math.max(stat.maxTime, entry.duration);
|
|
17594
|
+
stat.minTime = Math.min(stat.minTime, entry.duration);
|
|
17595
|
+
stat.avgTime = stat.totalTime / stat.count;
|
|
17596
|
+
});
|
|
17597
|
+
return {
|
|
17598
|
+
measurements: report,
|
|
17599
|
+
fps: getFPS(),
|
|
17600
|
+
currentMetrics: metricsRef.current[metricsRef.current.length - 1],
|
|
17601
|
+
allMetrics: [...metricsRef.current]
|
|
17602
|
+
};
|
|
17603
|
+
}, [getFPS]);
|
|
17604
|
+
const addMetrics = useCallback(
|
|
17605
|
+
(metrics) => {
|
|
17606
|
+
if (!enabled)
|
|
17607
|
+
return;
|
|
17608
|
+
const fullMetrics = {
|
|
17609
|
+
...metrics,
|
|
17610
|
+
timestamp: Date.now()
|
|
17611
|
+
};
|
|
17612
|
+
metricsRef.current.push(fullMetrics);
|
|
17613
|
+
if (metricsRef.current.length > 100) {
|
|
17614
|
+
metricsRef.current.shift();
|
|
17615
|
+
}
|
|
17616
|
+
},
|
|
17617
|
+
[enabled]
|
|
17618
|
+
);
|
|
17619
|
+
const clearMeasurements = useCallback(() => {
|
|
17620
|
+
performance.clearMarks();
|
|
17621
|
+
performance.clearMeasures();
|
|
17622
|
+
benchmarksRef.current.clear();
|
|
17623
|
+
metricsRef.current.length = 0;
|
|
17624
|
+
frameTimesRef.current.length = 0;
|
|
17625
|
+
}, []);
|
|
17626
|
+
const getMemoryUsage = useCallback(() => {
|
|
17627
|
+
if ("memory" in performance) {
|
|
17628
|
+
const memory = performance.memory;
|
|
17629
|
+
return memory ? memory.usedJSHeapSize : 0;
|
|
17630
|
+
}
|
|
17631
|
+
return 0;
|
|
17632
|
+
}, []);
|
|
17633
|
+
return {
|
|
17634
|
+
startMeasurement,
|
|
17635
|
+
endMeasurement,
|
|
17636
|
+
measureFunction,
|
|
17637
|
+
measureAsyncFunction,
|
|
17638
|
+
getPerformanceReport,
|
|
17639
|
+
addMetrics,
|
|
17640
|
+
clearMeasurements,
|
|
17641
|
+
updateFPS,
|
|
17642
|
+
getFPS,
|
|
17643
|
+
getMemoryUsage,
|
|
17644
|
+
enabled
|
|
17645
|
+
};
|
|
17646
|
+
};
|
|
17647
|
+
const useAdaptivePerformance = (thresholds) => {
|
|
17648
|
+
const { getFPS, getPerformanceReport } = usePerformanceMonitor();
|
|
17649
|
+
const performanceLevelRef = useRef("high");
|
|
17650
|
+
const updatePerformanceLevel = useCallback(() => {
|
|
17651
|
+
var _a;
|
|
17652
|
+
const fps = getFPS();
|
|
17653
|
+
const report = getPerformanceReport();
|
|
17654
|
+
const renderTime = ((_a = report.measurements["render"]) == null ? void 0 : _a.avgTime) || 0;
|
|
17655
|
+
if (fps < thresholds.fpsThreshold * 0.5 || renderTime > thresholds.renderTimeThreshold * 2) {
|
|
17656
|
+
performanceLevelRef.current = "low";
|
|
17657
|
+
} else if (fps < thresholds.fpsThreshold || renderTime > thresholds.renderTimeThreshold) {
|
|
17658
|
+
performanceLevelRef.current = "medium";
|
|
17659
|
+
} else {
|
|
17660
|
+
performanceLevelRef.current = "high";
|
|
17661
|
+
}
|
|
17662
|
+
return performanceLevelRef.current;
|
|
17663
|
+
}, [getFPS, getPerformanceReport, thresholds]);
|
|
17664
|
+
const getQualitySettings = useCallback(() => {
|
|
17665
|
+
const level = performanceLevelRef.current;
|
|
17666
|
+
switch (level) {
|
|
17667
|
+
case "low":
|
|
17668
|
+
return {
|
|
17669
|
+
enableAnimations: false,
|
|
17670
|
+
renderQuality: "low",
|
|
17671
|
+
maxVisibleTasks: 100,
|
|
17672
|
+
updateFrequency: 500
|
|
17673
|
+
// ms
|
|
17674
|
+
};
|
|
17675
|
+
case "medium":
|
|
17676
|
+
return {
|
|
17677
|
+
enableAnimations: true,
|
|
17678
|
+
renderQuality: "medium",
|
|
17679
|
+
maxVisibleTasks: 500,
|
|
17680
|
+
updateFrequency: 100
|
|
17681
|
+
};
|
|
17682
|
+
case "high":
|
|
17683
|
+
default:
|
|
17684
|
+
return {
|
|
17685
|
+
enableAnimations: true,
|
|
17686
|
+
renderQuality: "high",
|
|
17687
|
+
maxVisibleTasks: 1e3,
|
|
17688
|
+
updateFrequency: 16
|
|
17689
|
+
// 60fps
|
|
17690
|
+
};
|
|
17691
|
+
}
|
|
17692
|
+
}, []);
|
|
17693
|
+
return {
|
|
17694
|
+
performanceLevel: performanceLevelRef.current,
|
|
17695
|
+
updatePerformanceLevel,
|
|
17696
|
+
getQualitySettings
|
|
17697
|
+
};
|
|
17698
|
+
};
|
|
17699
|
+
const useIncrementalCoordinates = (visibleTasks, visibleTasksMirror, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, renderedRowIndexes, renderedColumnIndexes) => {
|
|
17700
|
+
const cacheRef = useRef({
|
|
17701
|
+
coordinates: /* @__PURE__ */ new Map(),
|
|
17702
|
+
lastUpdateParams: null
|
|
17703
|
+
});
|
|
17704
|
+
return useMemo(() => {
|
|
17705
|
+
const cache = cacheRef.current;
|
|
17706
|
+
const currentParams = {
|
|
17707
|
+
startDate,
|
|
17708
|
+
viewMode,
|
|
17709
|
+
rtl,
|
|
17710
|
+
fullRowHeight,
|
|
17711
|
+
taskHeight,
|
|
17712
|
+
taskYOffset,
|
|
17713
|
+
svgWidth,
|
|
17714
|
+
distances
|
|
17715
|
+
};
|
|
17716
|
+
const needsFullRecalc = !cache.lastUpdateParams || cache.lastUpdateParams.startDate.getTime() !== startDate.getTime() || cache.lastUpdateParams.viewMode !== viewMode || cache.lastUpdateParams.rtl !== rtl || cache.lastUpdateParams.fullRowHeight !== fullRowHeight || cache.lastUpdateParams.taskHeight !== taskHeight || cache.lastUpdateParams.taskYOffset !== taskYOffset || cache.lastUpdateParams.svgWidth !== svgWidth || JSON.stringify(cache.lastUpdateParams.distances) !== JSON.stringify(distances);
|
|
17717
|
+
if (needsFullRecalc) {
|
|
17718
|
+
cache.coordinates.clear();
|
|
17719
|
+
}
|
|
17720
|
+
const tasksToCalculate = /* @__PURE__ */ new Set();
|
|
17721
|
+
if (renderedRowIndexes && renderedColumnIndexes) {
|
|
17722
|
+
const [startRow, endRow] = renderedRowIndexes;
|
|
17723
|
+
const rowBuffer = Math.max(5, Math.ceil((endRow - startRow) * 0.5));
|
|
17724
|
+
const bufferedStartRow = Math.max(0, startRow - rowBuffer);
|
|
17725
|
+
const bufferedEndRow = endRow + rowBuffer;
|
|
17726
|
+
visibleTasks.forEach((task, index2) => {
|
|
17727
|
+
if (task.type === "empty" || !visibleTasksMirror[task.id])
|
|
17728
|
+
return;
|
|
17729
|
+
if (index2 >= bufferedStartRow && index2 <= bufferedEndRow) {
|
|
17730
|
+
tasksToCalculate.add(task.id);
|
|
17731
|
+
}
|
|
17732
|
+
});
|
|
17733
|
+
} else {
|
|
17734
|
+
visibleTasks.forEach((task) => {
|
|
17735
|
+
if (task.type !== "empty" && visibleTasksMirror[task.id]) {
|
|
17736
|
+
tasksToCalculate.add(task.id);
|
|
17737
|
+
}
|
|
17738
|
+
});
|
|
17739
|
+
}
|
|
17740
|
+
if (!needsFullRecalc) {
|
|
17741
|
+
for (const [taskId] of cache.coordinates) {
|
|
17742
|
+
if (!tasksToCalculate.has(taskId)) {
|
|
17743
|
+
cache.coordinates.delete(taskId);
|
|
17744
|
+
}
|
|
17745
|
+
}
|
|
17746
|
+
}
|
|
17747
|
+
const res = /* @__PURE__ */ new Map();
|
|
17748
|
+
visibleTasks.forEach((task) => {
|
|
17749
|
+
if (task.type === "empty" || !tasksToCalculate.has(task.id))
|
|
17750
|
+
return;
|
|
17751
|
+
const { id, comparisonLevel = 1 } = task;
|
|
17752
|
+
const cacheKey = `${id}_${comparisonLevel}`;
|
|
17753
|
+
let taskCoordinates = cache.coordinates.get(cacheKey);
|
|
17754
|
+
if (!taskCoordinates || needsFullRecalc) {
|
|
17755
|
+
taskCoordinates = countTaskCoordinates(
|
|
17756
|
+
task,
|
|
17757
|
+
taskToRowIndexMap,
|
|
17758
|
+
startDate,
|
|
17759
|
+
viewMode,
|
|
17760
|
+
rtl,
|
|
17761
|
+
fullRowHeight,
|
|
17762
|
+
taskHeight,
|
|
17763
|
+
taskYOffset,
|
|
17764
|
+
distances,
|
|
17765
|
+
svgWidth
|
|
17766
|
+
);
|
|
17767
|
+
cache.coordinates.set(cacheKey, taskCoordinates);
|
|
17768
|
+
}
|
|
17769
|
+
const resByLevel = res.get(comparisonLevel) || /* @__PURE__ */ new Map();
|
|
17770
|
+
resByLevel.set(id, taskCoordinates);
|
|
17771
|
+
res.set(comparisonLevel, resByLevel);
|
|
17772
|
+
});
|
|
17773
|
+
cache.lastUpdateParams = currentParams;
|
|
17774
|
+
return res;
|
|
17775
|
+
}, [
|
|
17776
|
+
visibleTasks,
|
|
17777
|
+
visibleTasksMirror,
|
|
17778
|
+
taskToRowIndexMap,
|
|
17779
|
+
startDate,
|
|
17780
|
+
viewMode,
|
|
17781
|
+
rtl,
|
|
17782
|
+
fullRowHeight,
|
|
17783
|
+
taskHeight,
|
|
17784
|
+
taskYOffset,
|
|
17785
|
+
distances,
|
|
17786
|
+
svgWidth,
|
|
17787
|
+
renderedRowIndexes,
|
|
17788
|
+
renderedColumnIndexes
|
|
17789
|
+
]);
|
|
17790
|
+
};
|
|
17481
17791
|
const fillMinAndMaxChildsMap = (resOnLevel, task, childTasksOnLevel) => {
|
|
17482
17792
|
const childs = childTasksOnLevel.get(task.id);
|
|
17483
17793
|
if (!childs || childs.length === 0) {
|
|
@@ -19097,6 +19407,11 @@ const Gantt = (props) => {
|
|
|
19097
19407
|
() => getChildsAndRoots(sortedTasks, null),
|
|
19098
19408
|
[sortedTasks]
|
|
19099
19409
|
);
|
|
19410
|
+
const adaptiveSettings = useAdaptivePerformance({
|
|
19411
|
+
fpsThreshold: 30,
|
|
19412
|
+
renderTimeThreshold: 16
|
|
19413
|
+
// 60fps = 16ms per frame
|
|
19414
|
+
});
|
|
19100
19415
|
const minAndMaxChildsMap = useMemo(
|
|
19101
19416
|
() => getMinAndMaxChildsMap(rootTasksMap, childTasksMap),
|
|
19102
19417
|
[rootTasksMap, childTasksMap]
|
|
@@ -19270,7 +19585,7 @@ const Gantt = (props) => {
|
|
|
19270
19585
|
svgWidth
|
|
19271
19586
|
]
|
|
19272
19587
|
);
|
|
19273
|
-
const
|
|
19588
|
+
const originalMapTaskToCoordinates = useMemo(
|
|
19274
19589
|
() => getMapTaskToCoordinates(
|
|
19275
19590
|
sortedTasks,
|
|
19276
19591
|
visibleTasksMirror,
|
|
@@ -19298,6 +19613,24 @@ const Gantt = (props) => {
|
|
|
19298
19613
|
visibleTasksMirror
|
|
19299
19614
|
]
|
|
19300
19615
|
);
|
|
19616
|
+
const optimizedMapTaskToCoordinates = useIncrementalCoordinates(
|
|
19617
|
+
visibleTasks,
|
|
19618
|
+
visibleTasksMirror,
|
|
19619
|
+
taskToRowIndexMap,
|
|
19620
|
+
startDate,
|
|
19621
|
+
viewMode,
|
|
19622
|
+
rtl,
|
|
19623
|
+
fullRowHeight,
|
|
19624
|
+
taskHeight,
|
|
19625
|
+
taskYOffset,
|
|
19626
|
+
distances,
|
|
19627
|
+
svgWidth,
|
|
19628
|
+
null,
|
|
19629
|
+
// renderedRowIndexes - can be integrated later with virtualization
|
|
19630
|
+
null
|
|
19631
|
+
// renderedColumnIndexes - can be integrated later with virtualization
|
|
19632
|
+
);
|
|
19633
|
+
const mapTaskToCoordinates = adaptiveSettings.performanceLevel === "high" ? optimizedMapTaskToCoordinates : originalMapTaskToCoordinates;
|
|
19301
19634
|
const scrollToTask = useCallback(
|
|
19302
19635
|
(task) => {
|
|
19303
19636
|
const { x1 } = getTaskCoordinates(task, mapTaskToCoordinates);
|