@@ -37,12 +37,11 @@ export interface CellProps<RecordType extends DefaultRecordType> {
3737 shouldCellUpdate ?: ( record : RecordType , prevRecord : RecordType ) => boolean ;
3838
3939 // 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 ;
4645 allColsFixedLeft ?: boolean ;
4746
4847 // ====================== Private Props ======================
@@ -104,12 +103,11 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
104103 rowSpan,
105104
106105 // Fixed
107- fixLeft,
108- fixRight,
109- firstFixLeft,
110- lastFixLeft,
111- firstFixRight,
112- lastFixRight,
106+ fixStart,
107+ fixEnd,
108+ fixedStartShadow,
109+ fixedEndShadow,
110+ zIndex,
113111
114112 // Private
115113 appendNode,
@@ -118,8 +116,7 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
118116 } = props ;
119117
120118 const cellPrefixCls = `${ prefixCls } -cell` ;
121- const { supportSticky, allColumnsFixedLeft, rowHoverable } = useContext ( TableContext , [
122- 'supportSticky' ,
119+ const { allColumnsFixedLeft, rowHoverable } = useContext ( TableContext , [
123120 'allColumnsFixedLeft' ,
124121 'rowHoverable' ,
125122 ] ) ;
@@ -136,16 +133,31 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
136133
137134 // ====================== Fixed =======================
138135 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 ;
141138
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 ;
145157 }
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 ;
149161 }
150162
151163 // ================ RowSpan & ColSpan =================
@@ -190,16 +202,20 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
190202 cellPrefixCls ,
191203 className ,
192204 {
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+
200216 [ `${ cellPrefixCls } -ellipsis` ] : ellipsis ,
201217 [ `${ cellPrefixCls } -with-append` ] : appendNode ,
202- [ `${ cellPrefixCls } -fix-sticky` ] : ( isFixLeft || isFixRight ) && isSticky && supportSticky ,
218+ [ `${ cellPrefixCls } -fix-sticky` ] : ( isFixStart || isFixEnd ) && isSticky ,
203219 [ `${ cellPrefixCls } -row-hover` ] : ! legacyCellProps && hovering ,
204220 } ,
205221 additionalProps . className ,
@@ -233,7 +249,7 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
233249 mergedChildNode = null ;
234250 }
235251
236- if ( ellipsis && ( lastFixLeft || firstFixRight ) ) {
252+ if ( ellipsis && ( fixedStartShadow || fixedEndShadow ) ) {
237253 mergedChildNode = < span className = { `${ cellPrefixCls } -content` } > { mergedChildNode } </ span > ;
238254 }
239255
0 commit comments