From 5d4b293e0a189efd19dc755c5aad8e3d20452dba Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 22 Jul 2021 09:56:26 -0400 Subject: [PATCH] Add comment about modulo operator Signed-off-by: Robin Townsend --- src/components/views/elements/ImageView.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/elements/ImageView.tsx b/src/components/views/elements/ImageView.tsx index 1979da5295..db63dbbfc2 100644 --- a/src/components/views/elements/ImageView.tsx +++ b/src/components/views/elements/ImageView.tsx @@ -188,6 +188,8 @@ export default class ImageView extends React.Component { // relative to the center of the image, accounting for rotation. let offsetX; 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) { case 0: offsetX = this.image.current.clientWidth / 2 - anchorX;