Add comment about modulo operator

Signed-off-by: Robin Townsend <robin@robin.town>
pull/21833/head
Robin Townsend 2021-07-22 09:56:26 -04:00
parent 9e0720a6c4
commit 5d4b293e0a
1 changed files with 2 additions and 0 deletions

View File

@ -188,6 +188,8 @@ export default class ImageView extends React.Component<IProps, IState> {
// relative to the center of the image, accounting for rotation. // relative to the center of the image, accounting for rotation.
let offsetX; let offsetX;
let offsetY; let offsetY;
// The modulo operator can return negative values for some
// rotations, so we have to do some extra work to normalize it
switch (((this.state.rotation % 360) + 360) % 360) { switch (((this.state.rotation % 360) + 360) % 360) {
case 0: case 0:
offsetX = this.image.current.clientWidth / 2 - anchorX; offsetX = this.image.current.clientWidth / 2 - anchorX;