1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | var _react = require("react");
|
8 |
|
9 |
|
10 |
|
11 | function useStickyOffsets(colWidths, flattenColumns, direction) {
|
12 | var stickyOffsets = (0, _react.useMemo)(function () {
|
13 | var columnCount = flattenColumns.length;
|
14 | var getOffsets = function getOffsets(startIndex, endIndex, offset) {
|
15 | var offsets = [];
|
16 | var total = 0;
|
17 | for (var i = startIndex; i !== endIndex; i += offset) {
|
18 | offsets.push(total);
|
19 | if (flattenColumns[i].fixed) {
|
20 | total += colWidths[i] || 0;
|
21 | }
|
22 | }
|
23 | return offsets;
|
24 | };
|
25 | var startOffsets = getOffsets(0, columnCount, 1);
|
26 | var endOffsets = getOffsets(columnCount - 1, -1, -1).reverse();
|
27 | return direction === 'rtl' ? {
|
28 | left: endOffsets,
|
29 | right: startOffsets
|
30 | } : {
|
31 | left: startOffsets,
|
32 | right: endOffsets
|
33 | };
|
34 | }, [colWidths, flattenColumns, direction]);
|
35 | return stickyOffsets;
|
36 | }
|
37 | var _default = exports.default = useStickyOffsets; |
\ | No newline at end of file |