Message List: Fix scroll freezing on iOS after swipe-to-back

This commit is contained in:
Alexander Zinchuk 2022-02-02 22:48:48 +01:00
parent 52e70c2f0e
commit 2e135c997b

View File

@ -203,7 +203,10 @@ const MiddleColumn: FC<StateProps> = ({
); );
const { isReady, handleOpenEnd, handleSlideStop } = useIsReady( const { isReady, handleOpenEnd, handleSlideStop } = useIsReady(
animationLevel, currentTransitionKey, prevTransitionKey, chatId, !shouldSkipHistoryAnimations && animationLevel !== ANIMATION_LEVEL_MIN,
currentTransitionKey,
prevTransitionKey,
chatId,
); );
useEffect(() => { useEffect(() => {
@ -608,7 +611,7 @@ export default memo(withGlobal(
)(MiddleColumn)); )(MiddleColumn));
function useIsReady( function useIsReady(
animationLevel?: number, withAnimations?: boolean,
currentTransitionKey?: number, currentTransitionKey?: number,
prevTransitionKey?: number, prevTransitionKey?: number,
chatId?: string, chatId?: string,
@ -618,7 +621,7 @@ function useIsReady(
const willSwitchMessageList = prevTransitionKey !== undefined && prevTransitionKey !== currentTransitionKey; const willSwitchMessageList = prevTransitionKey !== undefined && prevTransitionKey !== currentTransitionKey;
if (willSwitchMessageList) { if (willSwitchMessageList) {
if (animationLevel !== ANIMATION_LEVEL_MIN) { if (withAnimations) {
setIsReady(false); setIsReady(false);
} else { } else {
forceUpdate(); forceUpdate();
@ -626,10 +629,10 @@ function useIsReady(
} }
useOnChange(() => { useOnChange(() => {
if (animationLevel === ANIMATION_LEVEL_MIN) { if (!withAnimations) {
setIsReady(true); setIsReady(true);
} }
}, [animationLevel]); }, [withAnimations]);
function handleOpenEnd(e: React.TransitionEvent<HTMLDivElement>) { function handleOpenEnd(e: React.TransitionEvent<HTMLDivElement>) {
if (e.propertyName === 'transform' && e.target === e.currentTarget) { if (e.propertyName === 'transform' && e.target === e.currentTarget) {
@ -643,7 +646,7 @@ function useIsReady(
return { return {
isReady: isReady && !willSwitchMessageList, isReady: isReady && !willSwitchMessageList,
handleOpenEnd: animationLevel !== ANIMATION_LEVEL_MIN ? handleOpenEnd : undefined, handleOpenEnd: withAnimations ? handleOpenEnd : undefined,
handleSlideStop: animationLevel !== ANIMATION_LEVEL_MIN ? handleSlideStop : undefined, handleSlideStop: withAnimations ? handleSlideStop : undefined,
}; };
} }