Skip to content

Commit

Permalink
demo: fix the scroll area is scrolled to the bottom (#47186)
Browse files Browse the repository at this point in the history
Co-authored-by: heyongqiang <heyongqiang@qtrade.com.cn>
  • Loading branch information
boymax1 and heyongqiang committed Jan 27, 2024
1 parent 601d4db commit 33b1aa0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/list/demo/virtual-list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import VirtualList from 'rc-virtual-list';
import { Avatar, List, message } from 'antd';
import VirtualList from 'rc-virtual-list';

interface UserItem {
email: string;
Expand Down Expand Up @@ -39,7 +39,8 @@ const App: React.FC = () => {
}, []);

const onScroll = (e: React.UIEvent<HTMLElement, UIEvent>) => {
if (e.currentTarget.scrollHeight - e.currentTarget.scrollTop === ContainerHeight) {
// Refer to: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#problems_and_solutions
if (Math.abs(e.currentTarget.scrollHeight - e.currentTarget.scrollTop - ContainerHeight) <= 1) {
appendData();
}
};
Expand Down

0 comments on commit 33b1aa0

Please sign in to comment.