Moved map asset loading progress to use refs to stop re-renders

Moved map loading overlay to use animation frames for a smooth progress bar
This commit is contained in:
Mitchell McCaffrey
2020-06-28 13:37:04 +10:00
parent bf022e2686
commit a81031e84e
4 changed files with 82 additions and 26 deletions

View File

@@ -8,13 +8,12 @@ import MapFog from "./MapFog";
import MapDice from "./MapDice";
import MapGrid from "./MapGrid";
import MapMeasure from "./MapMeasure";
import MapLoadingOverlay from "./MapLoadingOverlay";
import TokenDataContext from "../../contexts/TokenDataContext";
import MapLoadingContext from "../../contexts/MapLoadingContext";
import TokenMenu from "../token/TokenMenu";
import TokenDragOverlay from "../token/TokenDragOverlay";
import LoadingOverlay from "../LoadingOverlay";
import { drawActionsToShapes } from "../../helpers/drawing";
@@ -36,7 +35,6 @@ function Map({
disabledTokens,
}) {
const { tokensById } = useContext(TokenDataContext);
const { isLoading, loadingProgress } = useContext(MapLoadingContext);
const gridX = map && map.gridX;
const gridY = map && map.gridY;
@@ -299,7 +297,7 @@ function Map({
{tokenMenu}
{tokenDragOverlay}
<MapDice />
{isLoading && <LoadingOverlay progress={loadingProgress} />}
<MapLoadingOverlay />
</>
}
selectedToolId={selectedToolId}