Adjust token menu to not hide rotation handle at 180deg
This commit is contained in:
parent
07b9f8f621
commit
3ad726f5ad
@ -152,10 +152,9 @@ function Token({
|
|||||||
onTokenDragEnd(event, tokenState.id);
|
onTokenDragEnd(event, tokenState.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClick(event: Konva.KonvaEventObject<MouseEvent>) {
|
function handleClick() {
|
||||||
if (draggable) {
|
if (draggable && tokenRef.current) {
|
||||||
const tokenImage = event.target;
|
onTokenMenuOpen(tokenState.id, tokenRef.current);
|
||||||
onTokenMenuOpen(tokenState.id, tokenImage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,12 +176,11 @@ function Token({
|
|||||||
}
|
}
|
||||||
// Check token click when locked and we are the map owner
|
// Check token click when locked and we are the map owner
|
||||||
// We can't use onClick because that doesn't check pointer distance
|
// We can't use onClick because that doesn't check pointer distance
|
||||||
if (tokenState.locked && map.owner === userId) {
|
if (tokenState.locked && map.owner === userId && tokenRef.current) {
|
||||||
// If down and up time is small trigger a click
|
// If down and up time is small trigger a click
|
||||||
const delta = event.evt.timeStamp - tokenPointerDownTimeRef.current;
|
const delta = event.evt.timeStamp - tokenPointerDownTimeRef.current;
|
||||||
if (delta < 300) {
|
if (delta < 300) {
|
||||||
const tokenImage = event.target;
|
onTokenMenuOpen(tokenState.id, tokenRef.current);
|
||||||
onTokenMenuOpen(tokenState.id, tokenImage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +217,7 @@ function Token({
|
|||||||
});
|
});
|
||||||
tokenRef.current.scaleX(1);
|
tokenRef.current.scaleX(1);
|
||||||
tokenRef.current.scaleY(1);
|
tokenRef.current.scaleY(1);
|
||||||
onTokenMenuOpen(tokenState.id, event.target);
|
onTokenMenuOpen(tokenState.id, tokenRef.current);
|
||||||
}
|
}
|
||||||
setIsTransforming(false);
|
setIsTransforming(false);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ function Transformer({
|
|||||||
onTransformEnd={handleTransformEnd}
|
onTransformEnd={handleTransformEnd}
|
||||||
centeredScaling={true}
|
centeredScaling={true}
|
||||||
rotationSnaps={[...Array(24).keys()].map((n) => n * 15)}
|
rotationSnaps={[...Array(24).keys()].map((n) => n * 15)}
|
||||||
rotateAnchorOffset={20}
|
rotateAnchorOffset={16}
|
||||||
enabledAnchors={["middle-left", "middle-right"]}
|
enabledAnchors={["middle-left", "middle-right"]}
|
||||||
flipEnabled={false}
|
flipEnabled={false}
|
||||||
ignoreStroke={true}
|
ignoreStroke={true}
|
||||||
|
@ -57,8 +57,8 @@ function TokenMenu({
|
|||||||
setMenuLeft(
|
setMenuLeft(
|
||||||
mapRect.left + imageRect.x + imageRect.width / 2 - 156 / 2
|
mapRect.left + imageRect.x + imageRect.width / 2 - 156 / 2
|
||||||
);
|
);
|
||||||
// Y 12px from the bottom
|
// Y 20px from the bottom
|
||||||
setMenuTop(mapRect.top + imageRect.y + imageRect.height + 12);
|
setMenuTop(mapRect.top + imageRect.y + imageRect.height + 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user