mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-11 16:49:44 +01:00
Message List: Fix scroll animation after window resize
This commit is contained in:
parent
b96643ea2a
commit
37ce132cce
@ -52,6 +52,7 @@ import resetScroll from '../../util/resetScroll';
|
||||
import fastSmoothScroll, { isAnimatingScroll } from '../../util/fastSmoothScroll';
|
||||
import renderText from '../common/helpers/renderText';
|
||||
import useLang, { LangFn } from '../../hooks/useLang';
|
||||
import useWindowSize from '../../hooks/useWindowSize';
|
||||
|
||||
import Loading from '../ui/Loading';
|
||||
import MessageScroll from './MessageScroll';
|
||||
@ -328,9 +329,11 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
};
|
||||
}, []);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
// Memorize height for scroll animation
|
||||
const { height: windowHeight } = useWindowSize();
|
||||
useEffect(() => {
|
||||
containerRef.current!.dataset.normalHeight = String(containerRef.current!.offsetHeight);
|
||||
}, []);
|
||||
}, [windowHeight]);
|
||||
|
||||
// Workaround for an iOS bug when animated stickers sometimes disappear
|
||||
useLayoutEffect(() => {
|
||||
|
@ -5,7 +5,7 @@ import { IDimensions } from '../modules/helpers';
|
||||
import { throttle } from '../util/schedulers';
|
||||
import windowSize from '../util/windowSize';
|
||||
|
||||
const RESIZE_TIMEOUT_MS = 250;
|
||||
const THROTTLE = 250;
|
||||
|
||||
export default () => {
|
||||
const [size, setSize] = useState<IDimensions>(windowSize.get());
|
||||
@ -13,14 +13,14 @@ export default () => {
|
||||
useEffect(() => {
|
||||
const handleResize = throttle(() => {
|
||||
setSize(windowSize.get());
|
||||
}, RESIZE_TIMEOUT_MS, false);
|
||||
}, THROTTLE, false);
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleResize);
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
|
||||
return size;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user