mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
fix: Allow Mobile Scroll During Message Stream (#984)
* fix(Icon/types): pick types from TMessage and TConversation * refactor: make abortScroll a global recoil state and change props/types for useScrollToRef * refactor(Message): invoke abort setter onTouchMove and onWheel, refactor(Messages): remove redundancy, reset abortScroll when scroll button is clicked
This commit is contained in:
parent
5d4b168df5
commit
7c0379ba51
7 changed files with 55 additions and 50 deletions
|
|
@ -1,7 +1,13 @@
|
|||
import { RefObject, useCallback } from 'react';
|
||||
import throttle from 'lodash/throttle';
|
||||
|
||||
export default function useScrollToRef(targetRef: RefObject<HTMLDivElement>, callback: () => void) {
|
||||
type TUseScrollToRef = {
|
||||
targetRef: RefObject<HTMLDivElement>;
|
||||
callback: () => void;
|
||||
smoothCallback: () => void;
|
||||
};
|
||||
|
||||
export default function useScrollToRef({ targetRef, callback, smoothCallback }: TUseScrollToRef) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const scrollToRef = useCallback(
|
||||
throttle(
|
||||
|
|
@ -20,7 +26,7 @@ export default function useScrollToRef(targetRef: RefObject<HTMLDivElement>, cal
|
|||
throttle(
|
||||
() => {
|
||||
targetRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||
callback();
|
||||
smoothCallback();
|
||||
},
|
||||
750,
|
||||
{ leading: true },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue