Skip to content

Commit 867ffe5

Browse files
committed
chore: fixed it
1 parent a5c1d8b commit 867ffe5

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

assets/index.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@
7979
bottom: 0;
8080
width: 5px;
8181
background: rgba(0, 0, 0, 0.5);
82+
opacity: 0;
8283
content: '';
84+
transition: opacity 0.3s;
85+
}
86+
87+
&-show::after {
88+
opacity: 1;
8389
}
8490
}
8591

docs/examples/scrollXY.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ const columns: TableProps['columns'] = [
2020

2121
const data = [
2222
{ a: '123', b: 'xxxxxxxx xxxxxxxx', d: 3, key: '1' },
23-
// { a: 'cdd', b: 'edd12221 edd12221', d: 3, key: '2' },
24-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '3' },
25-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '4' },
26-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '5' },
27-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '6' },
28-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '7' },
29-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '8' },
30-
// { a: '133', c: 'edd12221 edd12221', d: 2, key: '9' },
23+
{ a: 'cdd', b: 'edd12221 edd12221', d: 3, key: '2' },
24+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '3' },
25+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '4' },
26+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '5' },
27+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '6' },
28+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '7' },
29+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '8' },
30+
{ a: '133', c: 'edd12221 edd12221', d: 2, key: '9' },
3131
];
3232

3333
const Demo = () => {

src/Cell/index.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
121121
'rowHoverable',
122122
]);
123123

124-
useContext(TableContext, ({ scrollInfo }) => {
125-
if (fixedStartShadow) {
126-
console.log('~~~>', fixedStartShadow, scrollInfo);
127-
}
128-
});
129-
130124
// ====================== Value =======================
131125
const [childNode, legacyCellProps] = useCellRender(
132126
record,
@@ -142,6 +136,15 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
142136
const isFixStart = typeof fixStart === 'number';
143137
const isFixEnd = typeof fixEnd === 'number';
144138

139+
const [showFixStartShadow, showFixEndShadow] = useContext(TableContext, ({ scrollInfo }) => {
140+
const [scroll, scrollWidth] = scrollInfo;
141+
142+
const showStartShadow = isFixStart && fixedStartShadow && scroll > fixStart;
143+
const showEndShadow = isFixEnd && fixedEndShadow && scrollWidth - scroll > fixEnd;
144+
145+
return [showStartShadow, showEndShadow];
146+
});
147+
145148
if (isFixStart) {
146149
fixedStyle.insetInlineStart = fixStart as number;
147150
fixedStyle['--z-offset'] = zIndex;
@@ -205,7 +208,9 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
205208

206209
// Fixed shadow
207210
[`${cellPrefixCls}-fix-start-shadow`]: fixedStartShadow,
211+
[`${cellPrefixCls}-fix-start-shadow-show`]: fixedStartShadow && showFixStartShadow,
208212
[`${cellPrefixCls}-fix-end-shadow`]: fixedEndShadow,
213+
[`${cellPrefixCls}-fix-end-shadow-show`]: fixedEndShadow && showFixEndShadow,
209214

210215
[`${cellPrefixCls}-ellipsis`]: ellipsis,
211216
[`${cellPrefixCls}-with-append`]: appendNode,

src/utils/fixUtil.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ export interface FixedInfo {
1313
fixedEndShadow?: boolean;
1414

1515
zIndex?: number;
16-
17-
/** Get the scroll position of the scrollbar at
18-
* which the current `fixed: start` needs to display a shadow */
19-
stickyStart?: number;
20-
/** Get the scroll position of the scrollbar at
21-
* which the current `fixed: end` needs to display a shadow */
22-
stickyEnd?: number;
2316
}
2417

2518
function isFixedStart(column: { fixed?: FixedType }) {
@@ -58,7 +51,7 @@ export function getCellFixedInfo(
5851

5952
if (fixStart !== null) {
6053
fixedStartShadow = !columns[colEnd + 1] || !isFixedStart(columns[colEnd + 1]);
61-
zIndex = columns.length - colStart;
54+
zIndex = columns.length * 2 - colStart; // Fix start always overlay fix end
6255
}
6356
if (fixEnd !== null) {
6457
fixedEndShadow = !columns[colStart - 1] || !isFixedEnd(columns[colStart - 1]);

0 commit comments

Comments
 (0)