Skip to content

Commit

Permalink
chore(Table): add threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna authored and 潕量 committed Mar 25, 2022
1 parent 5e7c865 commit 301121d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/table/virtual.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import VirtualBody from './virtual/body';
import { statics } from './util';

const noop = () => {};
const THRESHOLD = 10;
export default function virtual(BaseComponent) {
class VirtualTable extends React.Component {
static VirtualBody = VirtualBody;
Expand Down Expand Up @@ -143,7 +144,9 @@ export default function virtual(BaseComponent) {
return 0;
}

return this.start * rowHeight;
const start = Math.max(this.start - THRESHOLD, 0);

return start * rowHeight;
}

getVisibleRange(ExpectStart) {
Expand Down Expand Up @@ -273,7 +276,7 @@ export default function virtual(BaseComponent) {
dataSource.forEach((current, index, record) => {
if (!current.hidden) {
count += 1;
if (count >= start && count < end) {
if (count >= Math.max(start - THRESHOLD, 0) && count < end) {
newDataSource.push(current);
}
}
Expand Down

0 comments on commit 301121d

Please sign in to comment.