Added loading spinner to map load
This commit is contained in:
parent
bf9c87341a
commit
86450a04db
@ -34,6 +34,7 @@ function Map({
|
|||||||
allowMapDrawing,
|
allowMapDrawing,
|
||||||
allowFogDrawing,
|
allowFogDrawing,
|
||||||
disabledTokens,
|
disabledTokens,
|
||||||
|
loading,
|
||||||
}) {
|
}) {
|
||||||
const mapSource = useDataSource(map, defaultMapSources);
|
const mapSource = useDataSource(map, defaultMapSources);
|
||||||
|
|
||||||
@ -296,6 +297,7 @@ function Map({
|
|||||||
aspectRatio={aspectRatio}
|
aspectRatio={aspectRatio}
|
||||||
isEnabled={selectedToolId === "pan"}
|
isEnabled={selectedToolId === "pan"}
|
||||||
controls={mapControls}
|
controls={mapControls}
|
||||||
|
loading={loading}
|
||||||
>
|
>
|
||||||
{map && mapImage}
|
{map && mapImage}
|
||||||
{map && mapDrawing}
|
{map && mapDrawing}
|
||||||
|
@ -5,11 +5,20 @@ import normalizeWheel from "normalize-wheel";
|
|||||||
|
|
||||||
import { MapInteractionProvider } from "../../contexts/MapInteractionContext";
|
import { MapInteractionProvider } from "../../contexts/MapInteractionContext";
|
||||||
|
|
||||||
|
import LoadingOverlay from "../LoadingOverlay";
|
||||||
|
|
||||||
const zoomSpeed = -0.001;
|
const zoomSpeed = -0.001;
|
||||||
const minZoom = 0.1;
|
const minZoom = 0.1;
|
||||||
const maxZoom = 5;
|
const maxZoom = 5;
|
||||||
|
|
||||||
function MapInteraction({ map, aspectRatio, isEnabled, children, controls }) {
|
function MapInteraction({
|
||||||
|
map,
|
||||||
|
aspectRatio,
|
||||||
|
isEnabled,
|
||||||
|
children,
|
||||||
|
controls,
|
||||||
|
loading,
|
||||||
|
}) {
|
||||||
const mapContainerRef = useRef();
|
const mapContainerRef = useRef();
|
||||||
const mapMoveContainerRef = useRef();
|
const mapMoveContainerRef = useRef();
|
||||||
const mapTranslateRef = useRef({ x: 0, y: 0 });
|
const mapTranslateRef = useRef({ x: 0, y: 0 });
|
||||||
@ -151,6 +160,7 @@ function MapInteraction({ map, aspectRatio, isEnabled, children, controls }) {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{controls}
|
{controls}
|
||||||
|
{loading && <LoadingOverlay />}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ function Game() {
|
|||||||
|
|
||||||
const [map, setMap] = useState(null);
|
const [map, setMap] = useState(null);
|
||||||
const [mapState, setMapState] = useState(null);
|
const [mapState, setMapState] = useState(null);
|
||||||
|
const [mapLoading, setMapLoading] = useState(false);
|
||||||
|
|
||||||
const canEditMapDrawing =
|
const canEditMapDrawing =
|
||||||
map !== null &&
|
map !== null &&
|
||||||
@ -272,6 +273,7 @@ function Game() {
|
|||||||
if (cachedMap && cachedMap.lastModified === newMap.lastModified) {
|
if (cachedMap && cachedMap.lastModified === newMap.lastModified) {
|
||||||
setMap(cachedMap);
|
setMap(cachedMap);
|
||||||
} else {
|
} else {
|
||||||
|
setMapLoading(true);
|
||||||
peer.connection.send({ id: "mapRequest" });
|
peer.connection.send({ id: "mapRequest" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -285,6 +287,7 @@ function Game() {
|
|||||||
}
|
}
|
||||||
// A new map response with a file attached
|
// A new map response with a file attached
|
||||||
if (data.id === "mapResponse") {
|
if (data.id === "mapResponse") {
|
||||||
|
setMapLoading(false);
|
||||||
if (data.data && data.data.type === "file") {
|
if (data.data && data.data.type === "file") {
|
||||||
// Convert file back to blob after peer transfer
|
// Convert file back to blob after peer transfer
|
||||||
const file = new Blob([data.data.file]);
|
const file = new Blob([data.data.file]);
|
||||||
@ -471,6 +474,7 @@ function Game() {
|
|||||||
map={map}
|
map={map}
|
||||||
mapState={mapState}
|
mapState={mapState}
|
||||||
tokens={tokens}
|
tokens={tokens}
|
||||||
|
loading={mapLoading}
|
||||||
onMapTokenStateChange={handleMapTokenStateChange}
|
onMapTokenStateChange={handleMapTokenStateChange}
|
||||||
onMapTokenStateRemove={handleMapTokenStateRemove}
|
onMapTokenStateRemove={handleMapTokenStateRemove}
|
||||||
onMapChange={handleMapChange}
|
onMapChange={handleMapChange}
|
||||||
|
Loading…
Reference in New Issue
Block a user