Skip to content

Commit

Permalink
fixed: disable scrol when scroll up
Browse files Browse the repository at this point in the history
  • Loading branch information
zzggo committed Feb 18, 2025
1 parent 5d4fccf commit 9615a50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/ui/views/NFT/GridTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const GridTab = forwardRef((props: GridTabProps, ref) => {

const [nfts, setNFTs] = useState<any[]>([]);

const [total, setTotal] = useState(0);
const [total, setTotal] = useState(1);

const [hasMore, setHasMore] = useState(true);

Expand Down Expand Up @@ -429,7 +429,7 @@ const GridTab = forwardRef((props: GridTabProps, ref) => {
<InfiniteScroll
dataLength={nfts.length}
next={nextPage}
hasMore={hasMore}
hasMore={hasMore && scrollDirection === 'down'}
loader={<LLSpinner />}
height="calc(100vh - 160px)"
style={{
Expand All @@ -438,6 +438,13 @@ const GridTab = forwardRef((props: GridTabProps, ref) => {
marginTop: '-16px',
}}
scrollThreshold="100px"
onScroll={(e: any) => {
const target = e.target as HTMLElement;
const scrollTop = target.scrollTop;
const direction = scrollTop > lastScrollTop.current ? 'down' : 'up';
setScrollDirection(direction);
lastScrollTop.current = scrollTop;
}}
>
<Grid container className={classes.grid}>
{nfts && nfts.map(createGridCard)}
Expand Down
11 changes: 9 additions & 2 deletions src/ui/views/NftEvm/GridTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const GridTab = forwardRef((props: GridTabProps, ref) => {

const [nfts, setNFTs] = useState<any[]>([]);

const [total, setTotal] = useState(0);
const [total, setTotal] = useState(1);

const [hasMore, setHasMore] = useState(true);

Expand Down Expand Up @@ -380,7 +380,7 @@ const GridTab = forwardRef((props: GridTabProps, ref) => {
<InfiniteScroll
dataLength={nfts.length}
next={nextPage}
hasMore={hasMore}
hasMore={hasMore && scrollDirection === 'down'}
loader={<LLSpinner />}
height="calc(100vh - 160px)"
style={{
Expand All @@ -389,6 +389,13 @@ const GridTab = forwardRef((props: GridTabProps, ref) => {
marginTop: '-16px',
}}
scrollThreshold="100px"
onScroll={(e: any) => {
const target = e.target as HTMLElement;
const scrollTop = target.scrollTop;
const direction = scrollTop > lastScrollTop.current ? 'down' : 'up';
setScrollDirection(direction);
lastScrollTop.current = scrollTop;
}}
>
<Grid container className={classes.grid}>
{nfts && nfts.map(createGridCard)}
Expand Down

0 comments on commit 9615a50

Please sign in to comment.