{ "id": "164801", "key": "TIMOB-24190", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-03-06T13:31:26.000+0000", "created": "2016-12-01T19:15:36.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "community", "notable", "position" ], "versions": [], "issuelinks": [], "assignee": { "name": "fmerzadyan", "key": "fmerzadyan2", "displayName": "Frankie Merzadyan", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-06T13:31:26.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Animating a view using transform and a 2DMatrix will return the left coordinate and not the new position. The new method {{getLocationOnScreen()}} will return the actual x/y value.\r\n\r\nExample\r\n\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: \"#fff\"\r\n});\r\n\r\nvar v = Ti.UI.createView({\r\n left: 0,\r\n top: 0,\r\n width: 100,\r\n height: 100,\r\n backgroundColor: \"#f00\"\r\n});\r\n\r\nvar dpi = Ti.Platform.displayCaps.logicalDensityFactor;\r\n\r\nwin.addEventListener(\"open\", function() {\r\n v.animate({\r\n left: 200,\r\n duration: 1000\r\n }, function() {\r\n console.log(\"Animate left:\");\r\n console.log(\"left: \" + v.left);\r\n console.log(\"rect.x: \" + v.rect.x);\r\n console.log(\"locationOnScreen: \" + v.getLocationOnScreen().x);\r\n console.log(\"------------------------\");\r\n\r\n var matrix = Ti.UI.create2DMatrix()\r\n matrix = matrix.translate(-200*dpi, 0);\r\n\r\n v.animate({\r\n transform: matrix,\r\n duration: 1000\r\n }, function() {\r\n console.log(\"Animate transform:\");\r\n console.log(\"left: \" + v.left);\r\n console.log(\"rect.x: \" + v.rect.x);\r\n console.log(\"locationOnScreen: \" + v.getLocationOnScreen().x);\r\n console.log(\"------------------------\");\r\n });\r\n });\r\n})\r\nwin.add(v);\r\nwin.open();\r\n{code}\r\n\r\nThe output will be:\r\n\r\n Animate left:\r\n left: 200\r\n rect.x: 200\r\n locationOnScreen: 200\r\n ------------------------\r\n Animate transform:\r\n left: 200 *<---- wrong, last left value*\r\n rect.x: 200 *<---- wrong, last left value*\r\n locationOnScreen: 0 *<-----correct position after translate*\r\n ------------------------\r\n\r\nIt can be very handy if you drag objects using translateX/translateY and want to check the actual position", "attachment": [], "flagged": false, "summary": "Android: Adding getLocationOnScreen() to retrieve location after translation", "creator": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Android", "comment": { "comments": [ { "id": "402464", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Danke Michael! [~fmerzadyan], can you do the CR & FT for this? Thx! *EDIT*: The community PR was revoked, so pulling it out of 6.1.0", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-12-02T14:40:51.000+0000", "updated": "2016-12-11T13:49:21.000+0000" }, { "id": "409299", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-06T13:31:26.000+0000", "updated": "2017-03-06T13:31:26.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }