Browse Source

add tentative scroll watcher

- commented out
- keeps scroll position after resize, but costs performance
master
jeffvli 3 years ago
parent
commit
581e559fc9
  1. 2
      src/components/viewtypes/ListViewTable.tsx
  2. 5
      src/components/viewtypes/ListViewType.tsx

2
src/components/viewtypes/ListViewTable.tsx

@ -35,6 +35,7 @@ const ListViewTable = ({
cacheImages, cacheImages,
autoHeight, autoHeight,
listType, listType,
// onScroll,
nowPlaying, nowPlaying,
}: any) => { }: any) => {
const history = useHistory(); const history = useHistory();
@ -73,6 +74,7 @@ const ListViewTable = ({
affixHorizontalScrollbar affixHorizontalScrollbar
shouldUpdateScroll={false} shouldUpdateScroll={false}
style={{ fontSize: `${fontSize}px` }} style={{ fontSize: `${fontSize}px` }}
// onScroll={onScroll}
> >
{columns.map((column: any) => ( {columns.map((column: any) => (
<Table.Column <Table.Column

5
src/components/viewtypes/ListViewType.tsx

@ -42,6 +42,7 @@ const ListViewType = (
const [dragSpeed, setDragSpeed] = useState(''); const [dragSpeed, setDragSpeed] = useState('');
const [height, setHeight] = useState(0); const [height, setHeight] = useState(0);
const [show, setShow] = useState(false); const [show, setShow] = useState(false);
// const [scrollY, setScrollY] = useState(0);
const [columns] = useState(tableColumns); const [columns] = useState(tableColumns);
const { getHeight } = DOMHelper; const { getHeight } = DOMHelper;
const wrapperRef = useRef<HTMLDivElement>(null); const wrapperRef = useRef<HTMLDivElement>(null);
@ -61,6 +62,7 @@ const ListViewType = (
window.clearTimeout(window.resizeInterval); window.clearTimeout(window.resizeInterval);
window.resizeInterval = window.setTimeout(() => { window.resizeInterval = window.setTimeout(() => {
setShow(true); setShow(true);
// tableRef?.current?.scrollTop(Math.abs(scrollY));
}, 500); }, 500);
setHeight(wrapperRef.current ? getHeight(wrapperRef.current) : 200); setHeight(wrapperRef.current ? getHeight(wrapperRef.current) : 200);
@ -110,6 +112,8 @@ const ListViewType = (
? currentScroll - scrollDistance ? currentScroll - scrollDistance
: currentScroll : currentScroll
); );
// setScrollY(currentScroll);
}, 50); }, 50);
return () => clearInterval(interval); return () => clearInterval(interval);
@ -273,6 +277,7 @@ const ListViewType = (
cacheImages={cacheImages} cacheImages={cacheImages}
listType={listType} listType={listType}
nowPlaying={rest.nowPlaying} nowPlaying={rest.nowPlaying}
// onScroll={(e) => setScrollY(tableRef.current.scrollY)}
/> />
)} )}
</div> </div>

Loading…
Cancel
Save