Changed hit detection for tokens to only enable when dragging a vehicle

This commit is contained in:
Mitchell McCaffrey 2021-01-02 09:41:18 +11:00
parent dfe8f0f53b
commit cc7db42894

View File

@ -17,9 +17,6 @@ import TokenLabel from "../token/TokenLabel";
import { tokenSources, unknownSource } from "../../tokens";
// Enable hit detection on drag to allow for vehicle tokens
Konva.hitOnDragEnabled = true;
const snappingThreshold = 1 / 7;
function MapToken({
@ -58,6 +55,9 @@ function MapToken({
const tokenImage = imageRef.current;
if (token && token.category === "vehicle") {
// Enable hit detection for .intersects() function
Konva.hitOnDragEnabled = true;
// Find all other tokens on the map
const layer = tokenGroup.getLayer();
const tokens = layer.find(".character");
@ -95,6 +95,8 @@ function MapToken({
const mountChanges = {};
if (token && token.category === "vehicle") {
Konva.hitOnDragEnabled = false;
const parent = tokenGroup.getParent();
const mountedTokens = tokenGroup.find(".character");
for (let mountedToken of mountedTokens) {