Skip to content

Commit 46983b3

Browse files
committed
Don't render a blank element when the file is not in view in file explorer. Smoother scrolling. Fixes #123
1 parent 219b5c3 commit 46983b3

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

src/views/Explorer/FilesView/FileComponent.js

+12-25
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {formatBytes} from "../../../utils/Tools";
77
import {performCopyFile, performMoveFile} from "../../../utils/API/API";
88
import {toast} from "react-toastify";
99
import * as PropTypes from "prop-types";
10-
import handleViewport from 'react-in-viewport';
1110
import MediaWidget, {isMedia} from "../../Base/MediaWidget/MediaWidget";
1211
import {PROP_ITEM} from "../../../utils/RclonePropTypes";
1312
import ErrorBoundary from "../../../ErrorHandling/ErrorBoundary";
@@ -154,24 +153,17 @@ class FileComponent extends React.Component {
154153
</div>
155154
)
156155
} else {
157-
if (inViewport) {
158-
element = connectDragSource(
159-
<tr className="pointer-cursor fadeIn">
160-
<td onClick={(e) => clickHandler(e, item)}>
161-
<FileIcon IsDir={IsDir} MimeType={MimeType}/>{" "}{Name}
162-
</td>
163-
<td>{Size === -1 ? "-" : formatBytes(Size, 2)}</td>
164-
<td className="d-none d-md-table-cell">{modTime.toLocaleDateString()}</td>
165-
<td><FileActions downloadHandle={downloadHandle} linkShareHandle={linkShareHandle}
166-
deleteHandle={deleteHandle} item={item}/></td>
167-
</tr>
168-
)
169-
} else {
170-
// not in view, render an empty div
171-
element = (<tr className={"pointer-cursor"} style={{height: "60px"}}>
172-
173-
</tr>)
174-
}
156+
element = connectDragSource(
157+
<tr className="pointer-cursor fadeIn">
158+
<td onClick={(e) => clickHandler(e, item)}>
159+
<FileIcon IsDir={IsDir} MimeType={MimeType}/>{" "}{Name}
160+
</td>
161+
<td>{Size === -1 ? "-" : formatBytes(Size, 2)}</td>
162+
<td className="d-none d-md-table-cell">{modTime.toLocaleDateString()}</td>
163+
<td><FileActions downloadHandle={downloadHandle} linkShareHandle={linkShareHandle}
164+
deleteHandle={deleteHandle} item={item}/></td>
165+
</tr>
166+
)
175167
}
176168
return <ErrorBoundary>
177169
{element}
@@ -237,9 +229,4 @@ FileComponent.propTypes = {
237229

238230
};
239231

240-
/**
241-
* Handles view port to check if the current item is visible on the screen.
242-
*/
243-
const MyViewPort = handleViewport(FileComponent, {rootMargin: '-1.0px'});
244-
245-
export default DragSource(ItemTypes.FILECOMPONENT, fileComponentSource, collect)(MyViewPort);
232+
export default DragSource(ItemTypes.FILECOMPONENT, fileComponentSource, collect)(FileComponent);

0 commit comments

Comments
 (0)