Created
October 5, 2020 18:39
-
-
Save scdekov/a815ef0e17fae3cbe1cc847f2c568f70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const moveBoxCorner = (box: BoundingBox, newCorner: Point) => { | |
if (box.resizingCorner === 'topLeft') { | |
return { | |
...box, | |
startX: newCorner.x, | |
startY: newCorner.y, | |
width: box.width + box.startX - newCorner.x, | |
height: box.height + box.startY - newCorner.y | |
} | |
} else if (box.resizingCorner === 'topRight') { | |
return { | |
...box, | |
startY: newCorner.y, | |
width: newCorner.x - box.startX, | |
height: box.height + box.startY - newCorner.y | |
} | |
} else if (box.resizingCorner === 'bottomRight') { | |
return { | |
...box, | |
width: newCorner.x - box.startX, | |
height: newCorner.y - box.startY, | |
} | |
} else if (box.resizingCorner === 'bottomLeft') { | |
return { | |
...box, | |
startX: newCorner.x, | |
width: box.width + box.startX - newCorner.x, | |
height: newCorner.y - box.startY | |
} | |
} | |
return box; | |
}; |
Author
scdekov
commented
Oct 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment