Skip to content

Commit e3f5938

Browse files
committed
chore(Table): add threshold
1 parent 0a4a311 commit e3f5938

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/table/virtual.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import VirtualBody from './virtual/body';
77
import { statics } from './util';
88

99
const noop = () => {};
10+
const THRESHOLD = 10;
1011
export default function virtual(BaseComponent) {
1112
class VirtualTable extends React.Component {
1213
static VirtualBody = VirtualBody;
@@ -143,7 +144,9 @@ export default function virtual(BaseComponent) {
143144
return 0;
144145
}
145146

146-
return this.start * rowHeight;
147+
const start = Math.max(this.start - THRESHOLD, 0);
148+
149+
return start * rowHeight;
147150
}
148151

149152
getVisibleRange(ExpectStart) {
@@ -273,7 +276,7 @@ export default function virtual(BaseComponent) {
273276
dataSource.forEach((current, index, record) => {
274277
if (!current.hidden) {
275278
count += 1;
276-
if (count >= start && count < end) {
279+
if (count >= Math.max(start - THRESHOLD, 0) && count < end) {
277280
newDataSource.push(current);
278281
}
279282
}

0 commit comments

Comments
 (0)