[TIMOB-28286] Android: Touch events should fire synchronously
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Closed |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.1, Release 10.0.0 |
Components | Android |
Labels | android, event, parity, touch |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-12-12T01:56:31.000+0000 |
Updated | 2021-01-19T18:48:43.000+0000 |
Description
*Summary:*
The following view events should fire immediately like how it works on iOS...
* touchstart
* touchmove
* touchend
* touchcancel
Currently, the above events are fired async on Android, which means they're one frame behind. The issue with this is that it makes it difficult to implement your own drag-and-drop interface because the drag affect looks jumpy/laggy.
*Steps to reproduce:*
Build and run the below on Android.
Drag one of the squares onscreen.
Notice the square does not drag smoothly under your finger. (It jumps around your finger.)
function createDragSquare(top, left, color) {
var view = Ti.UI.createView({
touchEnabled: true,
backgroundColor: color,
center: { x: left + 50, y: top + 50 },
width: 100,
height: 100,
});
view.addEventListener("touchmove", function(event) {
view.center = view.convertPointToView({ x: event.x, y: event.y }, window);
event.cancelBubble = true;
});
return view;
}
var window = Ti.UI.createWindow({ backgroundColor: "white" });
window.add(createDragSquare(40, 40, "red"));
window.add(createDragSquare(120, 120, "green"));
window.add(createDragSquare(200, 200, "blue"));
window.open();
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12340
FR Passed, waiting on Jenkins build.
merged to master for 10.0.0 target