[TIMOB-12842] 2D image transforms are inconsistent between iOS and Android
GitHub Issue | n/a |
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2018-11-15T00:49:42.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android, iOS |
Labels | n/a |
Reporter | Matt Langston |
Assignee | Unknown |
Created | 2013-02-25T03:48:10.000+0000 |
Updated | 2018-11-15T00:49:42.000+0000 |
Description
2D image transforms are inconsistent between iOS and Android. I have attached a project named "touches" which reproduces the problem.
The iOS app behaves the way I expect, while the Android app behaves different to what I expect (which I would described as confusing and erratic behavior).
The "touches" app draws some colored squares and allows the user to drag them around the screen. The colored squares are image views (i.e. created with Ti.UI.createImageView) and have two event listeners attached to them, "touchstart" and "touchmove".
The "touchstart" event listener simply records the initial (x, y) coordinates of the user's initial touch in a lexically scoped variable named "initialLocationInView".
The "touchmove" event listener calculates the (deltaX, deltaY) of the user's finger movement relative to "initialLocationInView" and sets the image view's "transform" property to a 2D translation matrix (i.e. created with Ti.UI.create2DMatrix) using "imageView.transform = transform.translate(deltaX, deltaY)".
On iOS the colored squares track my finger movement so that they are always beneath my finger. This is expected behavior.
On Android the colored squares *accelerate* in the direction of my *constant-velocity* drag, and they quickly fly off the screen given just a few millimeters of finger drag. This is unexpected behavior.
Additionally, the hit-test area of "touchmove" is confined to the original location of the image view when the app started and not its current location. In other words, lifting my finger and touching the colored square again does not generate "touchmove" events. However, touching in the original location of the image view (i.e. where it was when the app started) does generate "touchmove" events. This is also unexpected behavior.
Attachments
The issue is that touch event coordinate "units" are inconsistent between Android and iOS. On Android, the touch coordinates are hard-coded to pixels. On iOS, the touch coordinates are hard-coded to dips. This issue will be solved by ticket [TIMOB-25839] in Titanium 8.0.0.