From 04e23e1d299c9877eb75995d58938d047c4bed3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arno=C5=A1t=20Pleskot?= Date: Tue, 1 Aug 2023 16:30:45 +0200 Subject: [PATCH] fix: do not animate empty scene --- src/components/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 3544c756f..1889a1f7b 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2012,7 +2012,6 @@ class App extends React.Component { cursorButton, } = this.state; - // TODO: this could be replaced with memoization function like _.memoize() const canUseMemoizedConstraints = isShallowEqual(scrollConstraints, prevState.scrollConstraints ?? {}) && isShallowEqual( @@ -2058,7 +2057,8 @@ class App extends React.Component { shouldAnimate: isViewportOutsideOfConstrainedArea && this.state.cursorButton !== "down" && - prevState.zoom.value === this.state.zoom.value, + prevState.zoom.value === this.state.zoom.value && + this.scene.getElementsIncludingDeleted().length > 0, // Do not animate when app is initialized but scene is empty - this would cause flickering }); }