1
1
import { inject } from 'vue' ;
2
- import PropTypes , { withUndefined } from '../../_util/vue-types' ;
3
- import { measureScrollbar } from './utils' ;
2
+ import PropTypes from '../../_util/vue-types' ;
4
3
import BaseTable from './BaseTable' ;
5
4
6
5
export default {
7
6
name : 'BodyTable' ,
8
7
inheritAttrs : false ,
9
8
props : {
10
- fixed : withUndefined ( PropTypes . oneOfType ( [ PropTypes . string , PropTypes . looseBool ] ) ) ,
11
9
columns : PropTypes . array . isRequired ,
12
10
tableClassName : PropTypes . string . isRequired ,
13
11
handleBodyScroll : PropTypes . func . isRequired ,
@@ -25,7 +23,6 @@ export default {
25
23
const { prefixCls, scroll } = this . table ;
26
24
const {
27
25
columns,
28
- fixed,
29
26
tableClassName,
30
27
getRowKey,
31
28
handleBodyScroll,
@@ -35,34 +32,26 @@ export default {
35
32
} = this ;
36
33
let { useFixedHeader, saveRef } = this . table ;
37
34
const bodyStyle = { ...this . table . bodyStyle } ;
38
- const innerBodyStyle = { } ;
39
-
40
- if ( scroll . x || fixed ) {
41
- bodyStyle . overflowX = bodyStyle . overflowX || 'scroll' ;
42
- // Fix weired webkit render bug
43
- // https://github.com/ant-design/ant-design/issues/7783
44
- bodyStyle . WebkitTransform = 'translate3d (0, 0, 0)' ;
45
- }
46
35
47
36
if ( scroll . y ) {
48
37
// maxHeight will make fixed-Table scrolling not working
49
38
// so we only set maxHeight to body-Table here
50
39
let maxHeight = bodyStyle . maxHeight || scroll . y ;
51
40
maxHeight = typeof maxHeight === 'number' ? `${ maxHeight } px` : maxHeight ;
52
- if ( fixed ) {
53
- innerBodyStyle . maxHeight = maxHeight ;
54
- innerBodyStyle . overflowY = bodyStyle . overflowY || 'scroll' ;
55
- } else {
56
- bodyStyle . maxHeight = maxHeight ;
57
- }
41
+
42
+ bodyStyle . maxHeight = maxHeight ;
58
43
bodyStyle . overflowY = bodyStyle . overflowY || 'scroll' ;
59
44
useFixedHeader = true ;
45
+ }
60
46
61
- // Add negative margin bottom for scroll bar overflow bug
62
- const scrollbarWidth = measureScrollbar ( { direction : 'vertical' } ) ;
63
- if ( scrollbarWidth > 0 && fixed ) {
64
- bodyStyle . marginBottom = `-${ scrollbarWidth } px` ;
65
- bodyStyle . paddingBottom = '0px' ;
47
+ if ( scroll . x ) {
48
+ bodyStyle . overflowX = bodyStyle . overflowX || 'auto' ;
49
+ // Fix weired webkit render bug
50
+ // https://github.com/ant-design/ant-design/issues/7783
51
+ bodyStyle . WebkitTransform = 'translate3d (0, 0, 0)' ;
52
+
53
+ if ( ! scroll . y ) {
54
+ bodyStyle . overflowY = 'hidden' ;
66
55
}
67
56
}
68
57
@@ -71,37 +60,13 @@ export default {
71
60
tableClassName = { tableClassName }
72
61
hasHead = { ! useFixedHeader }
73
62
hasBody
74
- fixed = { fixed }
75
63
columns = { columns }
76
64
expander = { expander }
77
65
getRowKey = { getRowKey }
78
66
isAnyColumnsFixed = { isAnyColumnsFixed }
79
67
/>
80
68
) ;
81
69
82
- if ( fixed && columns . length ) {
83
- let refName ;
84
- if ( columns [ 0 ] . fixed === 'left' || columns [ 0 ] . fixed === true ) {
85
- refName = 'fixedColumnsBodyLeft' ;
86
- } else if ( columns [ 0 ] . fixed === 'right' ) {
87
- refName = 'fixedColumnsBodyRight' ;
88
- }
89
- delete bodyStyle . overflowX ;
90
- delete bodyStyle . overflowY ;
91
- return (
92
- < div key = "bodyTable" class = { `${ prefixCls } -body-outer` } style = { { ...bodyStyle } } >
93
- < div
94
- class = { `${ prefixCls } -body-inner` }
95
- style = { innerBodyStyle }
96
- ref = { saveRef ( refName ) }
97
- onWheel = { handleWheel }
98
- onScroll = { handleBodyScroll }
99
- >
100
- { baseTable }
101
- </ div >
102
- </ div >
103
- ) ;
104
- }
105
70
// Should provides `tabindex` if use scroll to enable keyboard scroll
106
71
const useTabIndex = scroll && ( scroll . x || scroll . y ) ;
107
72
0 commit comments