Skip to content

Commit 2f40da5

Browse files
committed
docs: update demo
1 parent ab53462 commit 2f40da5

4 files changed

Lines changed: 76 additions & 32 deletions

File tree

assets/index.less

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@
6868

6969
&-fix {
7070
position: sticky !important;
71+
z-index: calc(2 + var(--z-offset));
72+
}
73+
74+
&-fix-start-shadow,
75+
&-fix-end-shadow {
76+
&::after {
77+
position: absolute;
78+
top: 0;
79+
bottom: 0;
80+
width: 5px;
81+
background: rgba(0, 0, 0, 0.5);
82+
content: '';
83+
}
84+
}
85+
86+
&-fix-start-shadow::after {
87+
left: 100%;
88+
}
89+
&-fix-end-shadow::after {
90+
right: 100%;
7191
}
7292

7393
// &-fix-left,
@@ -132,24 +152,35 @@
132152
// }
133153
// }
134154

135-
// &&-ellipsis {
136-
// overflow: hidden;
137-
// white-space: nowrap;
138-
// text-overflow: ellipsis;
139-
140-
// // Fixed first or last should special process
141-
// &.@{tablePrefixCls}-cell-fix-left-first,
142-
// &.@{tablePrefixCls}-cell-fix-left-last,
143-
// &.@{tablePrefixCls}-cell-fix-right-first &.@{tablePrefixCls}-cell-fix-right-last {
144-
// overflow: visible;
145-
146-
// .@{tablePrefixCls}-cell-content {
147-
// display: block;
148-
// overflow: hidden;
149-
// text-overflow: ellipsis;
150-
// }
151-
// }
152-
// }
155+
&&-ellipsis {
156+
overflow: hidden;
157+
white-space: nowrap;
158+
text-overflow: ellipsis;
159+
160+
// Fixed first or last should special process
161+
&.@{tablePrefixCls}-cell-fix-start-shadow,
162+
&.@{tablePrefixCls}-cell-fix-end-shadow {
163+
overflow: visible;
164+
165+
.@{tablePrefixCls}-cell-content {
166+
display: block;
167+
overflow: hidden;
168+
text-overflow: ellipsis;
169+
}
170+
}
171+
172+
// &.@{tablePrefixCls}-cell-fix-left-first,
173+
// &.@{tablePrefixCls}-cell-fix-left-last,
174+
// &.@{tablePrefixCls}-cell-fix-right-first &.@{tablePrefixCls}-cell-fix-right-last {
175+
// overflow: visible;
176+
177+
// .@{tablePrefixCls}-cell-content {
178+
// display: block;
179+
// overflow: hidden;
180+
// text-overflow: ellipsis;
181+
// }
182+
// }
183+
}
153184

154185
&&-row-hover {
155186
background: #fff4f4;

docs/examples/scrollXY.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import Table from 'rc-table';
44
import '../../assets/index.less';
55

66
const columns: TableProps['columns'] = [
7-
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 },
7+
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'start' },
88
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100 },
9-
{ title: 'title3', dataIndex: 'c', key: 'c', width: 100 },
9+
{ title: 'title3', dataIndex: 'c', key: 'c', width: 100, fixed: 'start' },
1010
{ title: 'title4', dataIndex: 'b', key: 'd', width: 100 },
1111
{ title: 'title5', dataIndex: 'b', key: 'e', width: 100 },
1212
{ title: 'title6', dataIndex: 'b', key: 'f', width: 100 },
1313
{ title: 'title7', dataIndex: 'b', key: 'g', width: 100 },
1414
{ title: 'title8', dataIndex: 'b', key: 'h', width: 100 },
1515
{ title: 'title9', dataIndex: 'b', key: 'i', width: 100 },
16-
{ title: 'title10', dataIndex: 'b', key: 'j', width: 100 },
16+
{ title: 'title10', dataIndex: 'b', key: 'j', width: 100, fixed: 'end' },
1717
{ title: 'title11', dataIndex: 'b', key: 'k', width: 100 },
18-
{ title: 'title12', dataIndex: 'b', key: 'l', width: 100 },
18+
{ title: 'title12', dataIndex: 'b', key: 'l', width: 100, fixed: 'end' },
1919
];
2020

2121
const data = [

src/Cell/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface CellProps<RecordType extends DefaultRecordType> {
4141
fixEnd?: number | false;
4242
fixedStartShadow?: boolean;
4343
fixedEndShadow?: boolean;
44+
zIndex?: number;
4445
allColsFixedLeft?: boolean;
4546

4647
// ====================== Private Props ======================
@@ -106,6 +107,7 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
106107
fixEnd,
107108
fixedStartShadow,
108109
fixedEndShadow,
110+
zIndex,
109111

110112
// Private
111113
appendNode,
@@ -136,9 +138,11 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
136138

137139
if (isFixStart) {
138140
fixedStyle.insetInlineStart = fixStart as number;
141+
fixedStyle['--z-offset'] = zIndex;
139142
}
140143
if (isFixEnd) {
141144
fixedStyle.insetInlineEnd = fixEnd as number;
145+
fixedStyle['--z-offset'] = zIndex;
142146
}
143147

144148
// ================ RowSpan & ColSpan =================
@@ -194,6 +198,8 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
194198
// [`${cellPrefixCls}-fix-right-last`]: lastFixRight && supportSticky,
195199

196200
// Fixed shadow
201+
[`${cellPrefixCls}-fix-start-shadow`]: fixedStartShadow,
202+
[`${cellPrefixCls}-fix-end-shadow`]: fixedEndShadow,
197203

198204
[`${cellPrefixCls}-ellipsis`]: ellipsis,
199205
[`${cellPrefixCls}-with-append`]: appendNode,
@@ -231,9 +237,9 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
231237
mergedChildNode = null;
232238
}
233239

234-
// if (ellipsis && (lastFixLeft || firstFixRight)) {
235-
// mergedChildNode = <span className={`${cellPrefixCls}-content`}>{mergedChildNode}</span>;
236-
// }
240+
if (ellipsis && (fixedStartShadow || fixedEndShadow)) {
241+
mergedChildNode = <span className={`${cellPrefixCls}-content`}>{mergedChildNode}</span>;
242+
}
237243

238244
return (
239245
<Component

src/utils/fixUtil.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,31 @@ export function getCellFixedInfo(
4040
fixEnd = stickyOffsets.end[colEnd];
4141
}
4242

43-
console.log('fixStart:', colStart);
44-
4543
// check if need to add shadow
46-
const fixedStartShadow =
47-
fixStart !== null && (!columns[colStart + 1] || !isFixedStart(columns[colStart + 1]));
48-
const fixedEndShadow =
49-
fixEnd !== null && (!columns[colEnd - 1] || !isFixedEnd(columns[colEnd - 1]));
44+
let fixedStartShadow: boolean;
45+
let fixedEndShadow: boolean;
5046

5147
// Calc `zIndex`.
5248
// first fixed start (start -> end) column `zIndex` should be greater than next column.
5349
// first fixed end (end -> start) column `zIndex` should be greater than next column.
54-
// TODO: handle this
50+
51+
let zIndex = 0;
52+
53+
if (fixStart !== null) {
54+
fixedStartShadow = !columns[colEnd + 1] || !isFixedStart(columns[colEnd + 1]);
55+
zIndex = columns.length - colStart;
56+
}
57+
if (fixEnd !== null) {
58+
fixedEndShadow = !columns[colStart - 1] || !isFixedEnd(columns[colStart - 1]);
59+
zIndex = colEnd;
60+
}
5561

5662
return {
5763
fixStart,
5864
fixEnd,
5965
fixedStartShadow,
6066
fixedEndShadow,
6167
isSticky: stickyOffsets.isSticky,
68+
zIndex,
6269
};
6370
}

0 commit comments

Comments
 (0)