mirror of
https://github.com/markmanx/isoflow.git
synced 2025-02-07 20:10:47 +00:00
fix: fixes bug with rectangle resizing
This commit is contained in:
parent
ccbedd7c98
commit
0731757060
2 changed files with 18 additions and 4 deletions
|
@ -5,9 +5,9 @@ import {
|
|||
getItemAtTile,
|
||||
getBoundingBox,
|
||||
outermostCornerPositions,
|
||||
getTilePosition,
|
||||
convertBoundsToNamedAnchors,
|
||||
hasMovedTile
|
||||
hasMovedTile,
|
||||
isoToScreen
|
||||
} from 'src/utils';
|
||||
import { TRANSFORM_ANCHOR_SIZE } from 'src/config';
|
||||
import { ModeActions, AnchorPositionsEnum } from 'src/types';
|
||||
|
@ -74,9 +74,10 @@ export const TransformRectangle: ModeActions = {
|
|||
// Check if the user has mousedown'd on an anchor
|
||||
const rectangleBounds = getBoundingBox([rectangle.to, rectangle.from]);
|
||||
const anchorPositions = rectangleBounds.map((corner, i) => {
|
||||
return getTilePosition({
|
||||
return isoToScreen({
|
||||
tile: corner,
|
||||
origin: outermostCornerPositions[i]
|
||||
origin: outermostCornerPositions[i],
|
||||
rendererSize: uiState.rendererSize
|
||||
});
|
||||
});
|
||||
const activeAnchorIndex = anchorPositions.findIndex((anchorPosition) => {
|
||||
|
|
|
@ -104,6 +104,19 @@ export const getTilePosition = ({
|
|||
}
|
||||
};
|
||||
|
||||
type IsoToScreen = GetTilePosition & {
|
||||
rendererSize: Size;
|
||||
};
|
||||
|
||||
export const isoToScreen = ({ tile, origin, rendererSize }: IsoToScreen) => {
|
||||
const position = getTilePosition({ tile, origin });
|
||||
|
||||
return {
|
||||
x: position.x + rendererSize.width / 2,
|
||||
y: position.y + rendererSize.height / 2
|
||||
};
|
||||
};
|
||||
|
||||
export const sortByPosition = (tiles: Coords[]) => {
|
||||
const xSorted = [...tiles];
|
||||
const ySorted = [...tiles];
|
||||
|
|
Loading…
Reference in a new issue