@@ -37,12 +37,11 @@ export interface CellProps<RecordType extends DefaultRecordType> {
37
37
shouldCellUpdate ?: ( record : RecordType , prevRecord : RecordType ) => boolean ;
38
38
39
39
// Fixed
40
- fixLeft ?: number | false ;
41
- fixRight ?: number | false ;
42
- firstFixLeft ?: boolean ;
43
- lastFixLeft ?: boolean ;
44
- firstFixRight ?: boolean ;
45
- lastFixRight ?: boolean ;
40
+ fixStart ?: number | false ;
41
+ fixEnd ?: number | false ;
42
+ fixedStartShadow ?: boolean ;
43
+ fixedEndShadow ?: boolean ;
44
+ zIndex ?: number ;
46
45
allColsFixedLeft ?: boolean ;
47
46
48
47
// ====================== Private Props ======================
@@ -104,12 +103,11 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
104
103
rowSpan,
105
104
106
105
// Fixed
107
- fixLeft,
108
- fixRight,
109
- firstFixLeft,
110
- lastFixLeft,
111
- firstFixRight,
112
- lastFixRight,
106
+ fixStart,
107
+ fixEnd,
108
+ fixedStartShadow,
109
+ fixedEndShadow,
110
+ zIndex,
113
111
114
112
// Private
115
113
appendNode,
@@ -118,8 +116,7 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
118
116
} = props ;
119
117
120
118
const cellPrefixCls = `${ prefixCls } -cell` ;
121
- const { supportSticky, allColumnsFixedLeft, rowHoverable } = useContext ( TableContext , [
122
- 'supportSticky' ,
119
+ const { allColumnsFixedLeft, rowHoverable } = useContext ( TableContext , [
123
120
'allColumnsFixedLeft' ,
124
121
'rowHoverable' ,
125
122
] ) ;
@@ -136,16 +133,31 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
136
133
137
134
// ====================== Fixed =======================
138
135
const fixedStyle : React . CSSProperties = { } ;
139
- const isFixLeft = typeof fixLeft === 'number' && supportSticky ;
140
- const isFixRight = typeof fixRight === 'number' && supportSticky ;
136
+ const isFixStart = typeof fixStart === 'number' && ! allColumnsFixedLeft ;
137
+ const isFixEnd = typeof fixEnd === 'number' && ! allColumnsFixedLeft ;
141
138
142
- if ( isFixLeft ) {
143
- fixedStyle . position = 'sticky' ;
144
- fixedStyle . left = fixLeft as number ;
139
+ const [ showFixStartShadow , showFixEndShadow ] = useContext ( TableContext , ( { scrollInfo } ) => {
140
+ if ( ! isFixStart && ! isFixEnd ) {
141
+ return [ false , false ] ;
142
+ }
143
+
144
+ const [ scroll , scrollWidth ] = scrollInfo ;
145
+
146
+ const absScroll = Math . abs ( scroll ) ;
147
+
148
+ const showStartShadow = isFixStart && fixedStartShadow && absScroll > fixStart ;
149
+ const showEndShadow = isFixEnd && fixedEndShadow && scrollWidth - absScroll > fixEnd ;
150
+
151
+ return [ showStartShadow , showEndShadow ] ;
152
+ } ) ;
153
+
154
+ if ( isFixStart ) {
155
+ fixedStyle . insetInlineStart = fixStart as number ;
156
+ fixedStyle [ '--z-offset' ] = zIndex ;
145
157
}
146
- if ( isFixRight ) {
147
- fixedStyle . position = 'sticky' ;
148
- fixedStyle . right = fixRight as number ;
158
+ if ( isFixEnd ) {
159
+ fixedStyle . insetInlineEnd = fixEnd as number ;
160
+ fixedStyle [ '--z-offset' ] = zIndex ;
149
161
}
150
162
151
163
// ================ RowSpan & ColSpan =================
@@ -190,16 +202,20 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
190
202
cellPrefixCls ,
191
203
className ,
192
204
{
193
- [ `${ cellPrefixCls } -fix-left` ] : isFixLeft && supportSticky ,
194
- [ `${ cellPrefixCls } -fix-left-first` ] : firstFixLeft && supportSticky ,
195
- [ `${ cellPrefixCls } -fix-left-last` ] : lastFixLeft && supportSticky ,
196
- [ `${ cellPrefixCls } -fix-left-all` ] : lastFixLeft && allColumnsFixedLeft && supportSticky ,
197
- [ `${ cellPrefixCls } -fix-right` ] : isFixRight && supportSticky ,
198
- [ `${ cellPrefixCls } -fix-right-first` ] : firstFixRight && supportSticky ,
199
- [ `${ cellPrefixCls } -fix-right-last` ] : lastFixRight && supportSticky ,
205
+ // Fixed
206
+ [ `${ cellPrefixCls } -fix` ] : isFixStart || isFixEnd ,
207
+ [ `${ cellPrefixCls } -fix-start` ] : isFixStart ,
208
+ [ `${ cellPrefixCls } -fix-end` ] : isFixEnd ,
209
+
210
+ // Fixed shadow
211
+ [ `${ cellPrefixCls } -fix-start-shadow` ] : fixedStartShadow ,
212
+ [ `${ cellPrefixCls } -fix-start-shadow-show` ] : fixedStartShadow && showFixStartShadow ,
213
+ [ `${ cellPrefixCls } -fix-end-shadow` ] : fixedEndShadow ,
214
+ [ `${ cellPrefixCls } -fix-end-shadow-show` ] : fixedEndShadow && showFixEndShadow ,
215
+
200
216
[ `${ cellPrefixCls } -ellipsis` ] : ellipsis ,
201
217
[ `${ cellPrefixCls } -with-append` ] : appendNode ,
202
- [ `${ cellPrefixCls } -fix-sticky` ] : ( isFixLeft || isFixRight ) && isSticky && supportSticky ,
218
+ [ `${ cellPrefixCls } -fix-sticky` ] : ( isFixStart || isFixEnd ) && isSticky ,
203
219
[ `${ cellPrefixCls } -row-hover` ] : ! legacyCellProps && hovering ,
204
220
} ,
205
221
additionalProps . className ,
@@ -233,7 +249,7 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
233
249
mergedChildNode = null ;
234
250
}
235
251
236
- if ( ellipsis && ( lastFixLeft || firstFixRight ) ) {
252
+ if ( ellipsis && ( fixedStartShadow || fixedEndShadow ) ) {
237
253
mergedChildNode = < span className = { `${ cellPrefixCls } -content` } > { mergedChildNode } </ span > ;
238
254
}
239
255
0 commit comments