UNPKG

1.85 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getCellFixedInfo = getCellFixedInfo;
7function getCellFixedInfo(colStart, colEnd, columns, stickyOffsets, direction) {
8 var startColumn = columns[colStart] || {};
9 var endColumn = columns[colEnd] || {};
10 var fixLeft;
11 var fixRight;
12 if (startColumn.fixed === 'left') {
13 fixLeft = stickyOffsets.left[direction === 'rtl' ? colEnd : colStart];
14 } else if (endColumn.fixed === 'right') {
15 fixRight = stickyOffsets.right[direction === 'rtl' ? colStart : colEnd];
16 }
17 var lastFixLeft = false;
18 var firstFixRight = false;
19 var lastFixRight = false;
20 var firstFixLeft = false;
21 var nextColumn = columns[colEnd + 1];
22 var prevColumn = columns[colStart - 1];
23
24 // need show shadow only when canLastFix is true
25 var canLastFix = nextColumn && !nextColumn.fixed || prevColumn && !prevColumn.fixed || columns.every(function (col) {
26 return col.fixed === 'left';
27 });
28 if (direction === 'rtl') {
29 if (fixLeft !== undefined) {
30 var prevFixLeft = prevColumn && prevColumn.fixed === 'left';
31 firstFixLeft = !prevFixLeft && canLastFix;
32 } else if (fixRight !== undefined) {
33 var nextFixRight = nextColumn && nextColumn.fixed === 'right';
34 lastFixRight = !nextFixRight && canLastFix;
35 }
36 } else if (fixLeft !== undefined) {
37 var nextFixLeft = nextColumn && nextColumn.fixed === 'left';
38 lastFixLeft = !nextFixLeft && canLastFix;
39 } else if (fixRight !== undefined) {
40 var prevFixRight = prevColumn && prevColumn.fixed === 'right';
41 firstFixRight = !prevFixRight && canLastFix;
42 }
43 return {
44 fixLeft: fixLeft,
45 fixRight: fixRight,
46 lastFixLeft: lastFixLeft,
47 firstFixRight: firstFixRight,
48 lastFixRight: lastFixRight,
49 firstFixLeft: firstFixLeft,
50 isSticky: stickyOffsets.isSticky
51 };
52}
\No newline at end of file