[TIMOB-24317] Android: Extend Ti.UI.View "swipe" gesture properties using ScaleGestureDetector
| GitHub Issue | n/a | 
|---|---|
| Type | New Feature | 
| Priority | Low | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2018-10-22T19:06:34.000+0000 | 
| Affected Version/s | n/a | 
| Fix Version/s | Release 7.5.0 | 
| Components | Android | 
| Labels | community, event, notable, swipe | 
| Reporter | Hazem Khaled | 
| Assignee | Hans Knöchel | 
| Created | 2017-01-17T12:04:44.000+0000 | 
| Updated | 2018-10-22T19:07:07.000+0000 | 
Description
	Extend more properties from ScaleGestureDetector to TiView pinch event
*ref:*
https://developer.android.com/reference/android/view/ScaleGestureDetector.html
*New properties:*
* getCurrentSpan, getCurrentSpanX, getCurrentSpanY
* getEventTime, getTimeDelta
* getFocusX, getFocusY
* getPreviousSpan, getPreviousSpanX, getPreviousSpanY
* isInProgress _always true, maybe bug_
*Example:*
var win = Ti.UI.createWindow(),
    pinchView = Ti.UI.createView({
        backgroundColor: 'silver'
    }),
    pointView = Ti.UI.createView({
        backgroundColor: 'red',
        width: 40,
        height: 40,
        touchEnabled: false
    });
pinchView.add(pointView);
win.add(pinchView);
pinchView.addEventListener('pinch', function(e) {
    _.each(e, function(v, k) {
        if (k !== 'source') {
            console.log(k, v);
        }
    });
    pointView.applyProperties({
        center: {
            x: e.focusX / Ti.Platform.displayCaps.dpi * 160,
            y: e.focusY / Ti.Platform.displayCaps.dpi * 160
        }
    });
});
win.open();
pr: https://github.com/appcelerator/titanium_mobile/pull/8757
Can be scheduled for 6.2.0.
Hope we can put it into 6.1.0?
Nope, the 6.1.0 release is already full, we need to focus on the open tickets right now.
Using SDK Version
7.5.0.v20181010051919I get the following error when trying to "touch with 2 fingers, start pinch while you moving your fingers".[ERROR] : TiExceptionHandler: (main) [18710,18710] /app.js:16 [ERROR] : TiExceptionHandler: _.each(e, function (v, k) { [ERROR] : TiExceptionHandler: ^ [ERROR] : TiExceptionHandler: ReferenceError: _ is not defined [ERROR] : TiExceptionHandler: at View.<anonymous> (/app.js:16:5) [ERROR] : TiExceptionHandler: at View.value (ti:/events.js:49:21) [ERROR] : TiExceptionHandler: at View.value (ti:/events.js:101:19) [ERROR] : TiExceptionHandler: [ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [ERROR] : TiExceptionHandler: org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:63) [ERROR] : TiExceptionHandler: org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:971) [ERROR] : TiExceptionHandler: org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1196) [ERROR] : TiExceptionHandler: org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:401) [ERROR] : TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:102) [ERROR] : TiExceptionHandler: android.os.Looper.loop(Looper.java:193) [ERROR] : TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:6669) [ERROR] : TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiExceptionHandler: com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) [ERROR] : V8Exception: Exception occurred at /app.js:16: Uncaught ReferenceError: _ is not definedThis works fine on Alloy Applications just not Titanium.
[~smohammed] The sample above won't work in straight Titanium because the
_variable would need to be defined (it's exposed in Alloy as a global from a packaged library, underscore). That loop would need to be done in straight up JS, something like:for (var property in e) { if (property !== 'source') { console.log(property, e[property]); } }