mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-21 12:51:22 +01:00
[Perf] Animated Sticker: Avoid redundant data change on first render (#1576)
This commit is contained in:
parent
261ea66d5e
commit
8086003321
@ -60,6 +60,7 @@ const AnimatedSticker: FC<OwnProps> = ({
|
|||||||
const container = useRef<HTMLDivElement>(null);
|
const container = useRef<HTMLDivElement>(null);
|
||||||
const wasPlaying = useRef(false);
|
const wasPlaying = useRef(false);
|
||||||
const isFrozen = useRef(false);
|
const isFrozen = useRef(false);
|
||||||
|
const isFirstRender = useRef(true);
|
||||||
|
|
||||||
const playRef = useRef();
|
const playRef = useRef();
|
||||||
playRef.current = play;
|
playRef.current = play;
|
||||||
@ -194,8 +195,12 @@ const AnimatedSticker: FC<OwnProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (animation) {
|
if (animation) {
|
||||||
animation.changeData(animationData);
|
if (isFirstRender.current) {
|
||||||
playAnimation();
|
isFirstRender.current = false;
|
||||||
|
} else {
|
||||||
|
animation.changeData(animationData);
|
||||||
|
playAnimation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [playAnimation, animation, animationData]);
|
}, [playAnimation, animation, animationData]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user