1- import React , { useEffect , useRef , useState } from "react" ;
2- import type { ReactElement } from "react" ;
1+ import type { CSSProperties , ReactElement } from "react" ;
32import { motion } from "framer-motion" ;
43import type { MotionStyle } from "framer-motion" ;
54import type { RowComponentProps } from "react-window" ;
65
76import FileListItem from "./FileListItem" ;
8- import { FILE_ITEM_CONFIG } from "./utils/fileListConfig" ;
97import { getDynamicItemVariants , optimizedAnimationStyle } from "./utils/fileListAnimations" ;
108import type { VirtualListItemData } from "./utils/types" ;
119
@@ -15,8 +13,6 @@ const RowComponent = ({
1513 style,
1614 ...rowData
1715} : RowComponentProps < VirtualListItemData > ) : ReactElement => {
18- const rowRef = useRef < HTMLDivElement > ( null ) ;
19- const [ isVisible , setIsVisible ] = useState ( true ) ;
2016 const {
2117 contents,
2218 downloadingPath,
@@ -30,42 +26,15 @@ const RowComponent = ({
3026 isScrolling,
3127 scrollSpeed,
3228 highlightedIndex,
29+ rowPaddingBottom,
3330 } = rowData ;
3431
3532 const item = contents [ index ] ;
3633
37- useEffect ( ( ) => {
38- const element = rowRef . current ;
39- if ( element === null ) {
40- return ;
41- }
42-
43- const scrollContainer = element . closest ( '.virtual-file-list' ) ;
44-
45- const observer = new IntersectionObserver (
46- ( entries ) => {
47- entries . forEach ( ( entry ) => {
48- setIsVisible ( entry . isIntersecting ) ;
49- } ) ;
50- } ,
51- {
52- root : scrollContainer ?? null ,
53- rootMargin : "100px" ,
54- threshold : 0.01 ,
55- }
56- ) ;
57-
58- observer . observe ( element ) ;
59-
60- return ( ) => {
61- observer . disconnect ( ) ;
62- } ;
63- } , [ ] ) ;
6434
6535 if ( item === undefined ) {
6636 return (
6737 < div
68- ref = { rowRef }
6938 style = { style }
7039 { ...ariaAttributes }
7140 aria-hidden = "true"
@@ -75,7 +44,7 @@ const RowComponent = ({
7544
7645 const isHighlighted = highlightedIndex === index ;
7746
78- const adjustedStyle : React . CSSProperties = {
47+ const adjustedStyle : CSSProperties = {
7948 ...style ,
8049 boxSizing : "border-box" ,
8150 alignItems : "flex-start" ,
@@ -85,7 +54,7 @@ const RowComponent = ({
8554 height : "100%" ,
8655 width : "100%" ,
8756 paddingTop : 0 ,
88- paddingBottom : FILE_ITEM_CONFIG . spacing . marginBottom ,
57+ paddingBottom : rowPaddingBottom ,
8958 paddingRight : "12px" ,
9059 boxSizing : "border-box" ,
9160 ...optimizedAnimationStyle ,
@@ -95,11 +64,9 @@ const RowComponent = ({
9564
9665 return (
9766 < div
98- ref = { rowRef }
9967 style = { adjustedStyle }
10068 className = "file-list-item-container"
10169 { ...ariaAttributes }
102- aria-hidden = { ! isVisible ? "true" : undefined }
10370 data-oid = "_c:db-1"
10471 >
10572 < motion . div
@@ -122,18 +89,11 @@ const RowComponent = ({
12289 currentPath = { currentPath }
12390 contents = { contents }
12491 isHighlighted = { isHighlighted }
125- isVisible = { isVisible }
12692 data-oid = "k4zj3qr"
12793 />
12894 </ motion . div >
12995 </ div >
13096 ) ;
13197} ;
13298
133- const Row = React . memo ( RowComponent ) ;
134-
135- Row . displayName = "FileListRow" ;
136-
13799export { RowComponent } ;
138-
139- export default Row ;
0 commit comments