{ "id": "160421", "key": "TIMOB-23423", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": [ { "id": "16980", "description": "New V8", "name": "Release 6.0.0", "archived": false, "released": true, "releaseDate": "2016-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-06-27T06:48:59.000+0000", "created": "2016-05-21T14:09:10.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "community", "rotate", "scale", "transform" ], "versions": [ { "id": "17993", "description": "Release 5.2.2", "name": "Release 5.2.2", "archived": false, "released": true, "releaseDate": "2016-04-05" } ], "issuelinks": [], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-08-12T22:36:35.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": "Allow to set rotation (x,y,z) and scaling (x,y) to a view without the need of 2dmatrix. Similar to the existing translationX(), translationY() (with a small bugfix allowing to use views with borders, too).\r\n\r\nWith these settings it is possible to do smooth rotation/scaling in a drag event.\r\nGIF comparing 2dmatrix vs setters: http://migaweb.de/matrix.gif\r\n\r\nReference:\r\nhttps://developer.android.com/reference/android/view/View.html#setRotation%28float%29\r\n\r\nExample:\r\n\r\n{code:java}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: \"white\"\r\n});\r\nvar view = Ti.UI.createView({\r\n width: 150,\r\n height: 300,\r\n backgroundColor: \"red\",\r\n borderRadius: 10, touchEnabled:false\r\n})\r\nwin.add(view);\r\nvar sx = 0;\r\nvar sy = 0;\r\nvar cx = 0;\r\nvar cy = 0;\r\nvar dpi = Ti.Platform.displayCaps.logicalDensityFactor;\r\nvar WIDTH = Ti.Platform.displayCaps.platformWidth / dpi;\r\nvar HEIGHT = Ti.Platform.displayCaps.platformHeight / dpi;\r\n\r\nfunction onTouchStart(e) {\r\n // start movement\r\n sx = e.x;\r\n sy = e.y;\r\n cx = e.x;\r\n cy = e.y;\r\n}\r\n\r\nfunction onTouchMove(e) {\r\n var xDistance = cx - sx;\r\n var yDistance = cy - sy;\r\n\r\n var rotationStrength = Math.min(xDistance / (WIDTH), 1);\r\n var rotationAngel = (2 * Math.PI * rotationStrength / 16);\r\n \r\n var rotationStrengthX = Math.min(yDistance / (HEIGHT), 1);\r\n var rotationAngelX = (2 * Math.PI * rotationStrengthX / 16);\r\n \r\n var scaleStrength = 1 - Math.abs(rotationStrength) / 4;\r\n var scale = Math.max(scaleStrength, 0.93)\r\n\r\n view.rotation = rotationAngel * 20;\r\n view.rotationX = rotationAngelX * 20;\r\n view.translationX = xDistance;\r\n view.setTranslationY(yDistance);\r\n view.scaleX = scale;\r\n view.scaleY = scale;\r\n\r\n console.log(view.rotation);\r\n console.log(view.getScaleX());\r\n\r\n cx = e.x;\r\n cy = e.y;\r\n}\r\nwin.addEventListener(\"touchmove\", onTouchMove);\r\nwin.addEventListener(\"touchstart\", onTouchStart);\r\nwin.open();\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: Add rotation, rotationX, rotationY, scaleX, scaleY to view", "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", "closedSprints": [ { "id": 649, "state": "closed", "name": "2016 Sprint 13 SDK", "startDate": "2016-06-18T00:25:17.303Z", "endDate": "2016-07-02T00:25:00.000Z", "completeDate": "2016-07-04T04:25:16.889Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "386398", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/8010", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-21T14:11:47.000+0000", "updated": "2016-05-21T14:11:47.000+0000" }, { "id": "386677", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR tested and looks good. Waiting for 5.4.0 branch to be created so we can merge it into master. Thanks for the PR", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-24T20:54:06.000+0000", "updated": "2016-05-24T20:54:06.000+0000" }, { "id": "386686", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks! \r\n\r\nPerhaps someone can implement rotationX/Y and scaleX/Y for parity on iOS. CATransform3DRotate/CATransform3DScale should be equivalent functions (they are used in the 3dmatrix already)", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-24T21:32:26.000+0000", "updated": "2016-05-24T21:32:26.000+0000" }, { "id": "386725", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Thanks [~michael]! Will appreciate if you could create a parity ticket for the iOS :)", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-05-25T03:14:23.000+0000", "updated": "2016-05-25T03:14:23.000+0000" }, { "id": "393057", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the improvement.\r\n\r\nRotation, rotation X, rotation Y, scale X, scale Y are now added to view.\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201607250649\r\nTi SDK : 6.0.0.v20160811221444\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.1\r\nMAC El Capitan : 10.11.6\r\nAppc NPM : 4.2.7\r\nAppc CLI : 6.0.0-24\r\nNode: 4.4.4\r\nNexus 5 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-08-12T22:36:23.000+0000", "updated": "2016-08-12T22:36:23.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }