Fixed bug with tokens that were attatched to a vehicle being rendered on top of fog
This commit is contained in:
parent
7252efc7e9
commit
58ac649aa8
@ -1,4 +1,5 @@
|
||||
import React, { useState, useContext, useEffect } from "react";
|
||||
import { Group } from "react-konva";
|
||||
|
||||
import MapControls from "./MapControls";
|
||||
import MapInteraction from "./MapInteraction";
|
||||
@ -208,37 +209,39 @@ function Map({
|
||||
}
|
||||
}
|
||||
|
||||
const mapTokens =
|
||||
mapState &&
|
||||
Object.values(mapState.tokens)
|
||||
.sort(sortMapTokenStates)
|
||||
.map((tokenState) => (
|
||||
<MapToken
|
||||
key={tokenState.id}
|
||||
token={tokensById[tokenState.tokenId]}
|
||||
tokenState={tokenState}
|
||||
tokenSizePercent={tokenSizePercent}
|
||||
onTokenStateChange={onMapTokenStateChange}
|
||||
onTokenMenuOpen={handleTokenMenuOpen}
|
||||
onTokenDragStart={(e) =>
|
||||
setDraggingTokenOptions({
|
||||
dragging: true,
|
||||
tokenState,
|
||||
tokenGroup: e.target,
|
||||
})
|
||||
}
|
||||
onTokenDragEnd={() =>
|
||||
setDraggingTokenOptions({
|
||||
...draggingTokenOptions,
|
||||
dragging: false,
|
||||
})
|
||||
}
|
||||
draggable={
|
||||
selectedToolId === "pan" && !(tokenState.id in disabledTokens)
|
||||
}
|
||||
mapState={mapState}
|
||||
/>
|
||||
));
|
||||
const mapTokens = mapState && (
|
||||
<Group>
|
||||
{Object.values(mapState.tokens)
|
||||
.sort(sortMapTokenStates)
|
||||
.map((tokenState) => (
|
||||
<MapToken
|
||||
key={tokenState.id}
|
||||
token={tokensById[tokenState.tokenId]}
|
||||
tokenState={tokenState}
|
||||
tokenSizePercent={tokenSizePercent}
|
||||
onTokenStateChange={onMapTokenStateChange}
|
||||
onTokenMenuOpen={handleTokenMenuOpen}
|
||||
onTokenDragStart={(e) =>
|
||||
setDraggingTokenOptions({
|
||||
dragging: true,
|
||||
tokenState,
|
||||
tokenGroup: e.target,
|
||||
})
|
||||
}
|
||||
onTokenDragEnd={() =>
|
||||
setDraggingTokenOptions({
|
||||
...draggingTokenOptions,
|
||||
dragging: false,
|
||||
})
|
||||
}
|
||||
draggable={
|
||||
selectedToolId === "pan" && !(tokenState.id in disabledTokens)
|
||||
}
|
||||
mapState={mapState}
|
||||
/>
|
||||
))}
|
||||
</Group>
|
||||
);
|
||||
|
||||
const tokenMenu = (
|
||||
<TokenMenu
|
||||
|
@ -78,12 +78,12 @@ function MapToken({
|
||||
|
||||
const mountChanges = {};
|
||||
if (token && token.isVehicle) {
|
||||
const layer = tokenGroup.getLayer();
|
||||
const parent = tokenGroup.getParent();
|
||||
const mountedTokens = tokenGroup.find(".token");
|
||||
for (let mountedToken of mountedTokens) {
|
||||
// Save and restore token position after moving layer
|
||||
const position = mountedToken.absolutePosition();
|
||||
mountedToken.moveTo(layer);
|
||||
mountedToken.moveTo(parent);
|
||||
mountedToken.absolutePosition(position);
|
||||
mountChanges[mountedToken.id()] = {
|
||||
...mapState.tokens[mountedToken.id()],
|
||||
|
Loading…
Reference in New Issue
Block a user