@@ -100,6 +100,16 @@ export default function virtual(BaseComponent) {
100
100
} ) ;
101
101
}
102
102
103
+ if ( this . state . rowHeight && 'rowHeight' in nextProps ) {
104
+ const row = this . getRowNode ( ) ;
105
+ const rowClientHeight = row && row . clientHeight ;
106
+ if ( rowClientHeight !== this . state . rowHeight ) {
107
+ this . setState ( {
108
+ rowHeight : rowClientHeight
109
+ } ) ;
110
+ }
111
+ }
112
+
103
113
}
104
114
105
115
componentDidUpdate ( ) {
@@ -140,19 +150,21 @@ export default function virtual(BaseComponent) {
140
150
141
151
getVisibleRange ( ExpectStart ) {
142
152
const { height, rowHeight } = this . state ;
153
+ const len = this . props . dataSource . length ;
154
+
143
155
let end , visibleCount = 0 ;
144
156
let start = 0 ;
145
157
if ( typeof rowHeight === 'function' ) {
146
158
// try get cell height;
147
- end = 2 ;
159
+ end = 1 ;
148
160
} else {
149
161
visibleCount = parseInt ( height / rowHeight , 10 ) ;
150
162
151
163
if ( 'number' === typeof ExpectStart ) {
152
- start = ExpectStart ;
164
+ start = ExpectStart < len ? ExpectStart : 0 ;
153
165
}
154
166
155
- end = + start + 1 + visibleCount + 10 ;
167
+ end = Math . min ( + start + 1 + visibleCount + 10 , len ) ;
156
168
}
157
169
this . end = end ;
158
170
this . visibleCount = visibleCount ;
@@ -172,11 +184,16 @@ export default function virtual(BaseComponent) {
172
184
if ( this . hasVirtualData ) {
173
185
const body = this . bodyNode ;
174
186
const virtualScrollNode = body . querySelector ( 'div' ) ;
175
- const table = virtualScrollNode . querySelector ( 'table' ) ;
176
187
const { clientHeight, clientWidth } = body ;
177
- const { clientWidth : tableClientWidth } = table ;
178
- if ( clientWidth < tableClientWidth ) {
179
- dom . setStyle ( virtualScrollNode , 'width' , tableClientWidth ) ;
188
+
189
+ const tableInc = this . tableInc ;
190
+ const tableNode = findDOMNode ( tableInc ) ;
191
+ const { prefix } = this . props ;
192
+ const headerNode = tableNode . querySelector ( `.${ prefix } table-header table` ) ;
193
+ const headerClientWidth = headerNode && headerNode . clientWidth ;
194
+
195
+ if ( clientWidth < headerClientWidth ) {
196
+ dom . setStyle ( virtualScrollNode , 'min-width' , headerClientWidth ) ;
180
197
const leftNode = this . bodyLeftNode ;
181
198
const rightNode = this . bodyRightNode ;
182
199
leftNode && dom . setStyle ( leftNode , 'max-height' , clientHeight ) ;
@@ -223,7 +240,7 @@ export default function virtual(BaseComponent) {
223
240
}
224
241
225
242
getRowNode ( ) {
226
- return findDOMNode ( this . tableInc . getRowRef ( 1 ) ) ;
243
+ return findDOMNode ( this . tableInc . getRowRef ( 0 ) ) ;
227
244
}
228
245
229
246
render ( ) {
0 commit comments