{"action":"created","issue":{"url":"https://api.github.com/repos/mosch/react-avatar-editor/issues/7","labels_url":"https://api.github.com/repos/mosch/react-avatar-editor/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/mosch/react-avatar-editor/issues/7/comments","events_url":"https://api.github.com/repos/mosch/react-avatar-editor/issues/7/events","html_url":"https://github.com/mosch/react-avatar-editor/issues/7","id":55224304,"number":7,"title":"Is `calculatePosition` giving out the right x and y?","user":{"login":"chengyin","id":128819,"avatar_url":"https://avatars.githubusercontent.com/u/128819?v=3","gravatar_id":"","url":"https://api.github.com/users/chengyin","html_url":"https://github.com/chengyin","followers_url":"https://api.github.com/users/chengyin/followers","following_url":"https://api.github.com/users/chengyin/following{/other_user}","gists_url":"https://api.github.com/users/chengyin/gists{/gist_id}","starred_url":"https://api.github.com/users/chengyin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chengyin/subscriptions","organizations_url":"https://api.github.com/users/chengyin/orgs","repos_url":"https://api.github.com/users/chengyin/repos","events_url":"https://api.github.com/users/chengyin/events{/privacy}","received_events_url":"https://api.github.com/users/chengyin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-22T23:26:11Z","updated_at":"2015-02-23T08:02:24Z","closed_at":null,"body":"I'm running issues with images being rendered out of bound on the y-axis - the image's y origin will be at the bottom border (max y).\r\n\r\nAfter some tracing I think `calculatePosition` function may be the one that causing the issue. However, since I couldn't figure out what is the intend of the original code, I figured it is better to open an issue instead of the pull request.\r\n\r\nI did this change:\r\n\r\n```diff\r\ndiff --git a/index.js b/index.js\r\nindex d75e0e2..3ad6739 100644\r\n--- a/index.js\r\n+++ b/index.js\r\n@@ -120,8 +120,8 @@\r\n                 var lastX = this.state.image.x;\r\n                 var lastY = this.state.image.y;\r\n \r\n-                var x = Math.round((width  + lastX <= borderX) ? lastX + (borderX - (width  + lastX)) : lastX);\r\n-                var y = Math.round((height + lastY <= borderY) ? lastY + (borderY - (height + lastY)) : lastY);\r\n+                var x = Math.round((height + lastX <= borderX) ? lastX + (borderX - (height + lastX)) : lastX);\r\n+                var y = Math.round((width  + lastY <= borderY) ? lastY + (borderY - (width  + lastY)) : lastY);\r\n \r\n                 return {\r\n                     x: x,\r\n```\r\n\r\nand for my use case this did resolve the bug I saw.\r\n\r\nI found it strange that while `borderX` is calculated based on `dimensions.height`, here calculating `x` was done with `width`, instead of `height`."},"comment":{"url":"https://api.github.com/repos/mosch/react-avatar-editor/issues/comments/75502685","html_url":"https://github.com/mosch/react-avatar-editor/issues/7#issuecomment-75502685","issue_url":"https://api.github.com/repos/mosch/react-avatar-editor/issues/7","id":75502685,"user":{"login":"mosch","id":224866,"avatar_url":"https://avatars.githubusercontent.com/u/224866?v=3","gravatar_id":"","url":"https://api.github.com/users/mosch","html_url":"https://github.com/mosch","followers_url":"https://api.github.com/users/mosch/followers","following_url":"https://api.github.com/users/mosch/following{/other_user}","gists_url":"https://api.github.com/users/mosch/gists{/gist_id}","starred_url":"https://api.github.com/users/mosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosch/subscriptions","organizations_url":"https://api.github.com/users/mosch/orgs","repos_url":"https://api.github.com/users/mosch/repos","events_url":"https://api.github.com/users/mosch/events{/privacy}","received_events_url":"https://api.github.com/users/mosch/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T08:02:24Z","updated_at":"2015-02-23T08:02:24Z","body":"@ralphie02 you realise this when you drag the image? or when you get the cropped image? "}}