mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 01:05:20 +03:00
scroll into view
This commit is contained in:
parent
4895a533cc
commit
0eefea6d0b
@ -15,20 +15,17 @@ export default function Event({ eventId, close, scrollRef }) {
|
|||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const { data, status } = useEvent(eventId);
|
const { data, status } = useEvent(eventId);
|
||||||
const [showDialog, setShowDialog] = useState(false);
|
const [showDialog, setShowDialog] = useState(false);
|
||||||
|
const [shouldScroll, setShouldScroll] = useState(true);
|
||||||
const [deleteStatus, setDeleteStatus] = useState(FetchStatus.NONE);
|
const [deleteStatus, setDeleteStatus] = useState(FetchStatus.NONE);
|
||||||
const setDeleteEvent = useDelete();
|
const setDeleteEvent = useDelete();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Call Events.js scroll when this event has been mounted.
|
// Scroll event into view when component has been mounted.
|
||||||
// scrollIntoView(eventId);
|
if (shouldScroll && scrollRef && scrollRef[eventId]) {
|
||||||
scrollToElement();
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
const scrollToElement = useCallback(() => {
|
|
||||||
if (scrollRef && scrollRef[eventId]) {
|
|
||||||
scrollRef[eventId].scrollIntoView();
|
scrollRef[eventId].scrollIntoView();
|
||||||
|
setShouldScroll(false);
|
||||||
}
|
}
|
||||||
}, [scrollRef]);
|
}, [data, scrollRef, eventId, shouldScroll]);
|
||||||
|
|
||||||
const handleClickDelete = () => {
|
const handleClickDelete = () => {
|
||||||
setShowDialog(true);
|
setShowDialog(true);
|
||||||
|
|||||||
@ -80,7 +80,6 @@ export default function Events({ path: pathname, limit = API_LIMIT } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data && Array.isArray(data) && data.length + deleted < limit) {
|
if (data && Array.isArray(data) && data.length + deleted < limit) {
|
||||||
console.log('reached end');
|
|
||||||
dispatch({ type: 'REACHED_END', meta: { searchString } });
|
dispatch({ type: 'REACHED_END', meta: { searchString } });
|
||||||
}
|
}
|
||||||
}, [data, limit, searchString, searchStrings, deleted]);
|
}, [data, limit, searchString, searchStrings, deleted]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user