Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24317] Android: Extend Ti.UI.View "swipe" gesture properties using ScaleGestureDetector

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-10-22T19:06:34.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelscommunity, event, notable, swipe
ReporterHazem Khaled
AssigneeHans Knöchel
Created2017-01-17T12:04:44.000+0000
Updated2018-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();
Test: touch with 2 fingers, start pinch while you moving your fingers Expected: the red point keep in the center between your fingers

Comments

  1. Hazem Khaled 2017-01-17

    pr: https://github.com/appcelerator/titanium_mobile/pull/8757
  2. Hans Knöchel 2017-01-17

    Can be scheduled for 6.2.0.
  3. Hazem Khaled 2017-01-17

    Hope we can put it into 6.1.0?
  4. Hans Knöchel 2017-01-17

    Nope, the 6.1.0 release is already full, we need to focus on the open tickets right now.
  5. Samir Mohammed 2018-10-15

    Using SDK Version 7.5.0.v20181010051919 I 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 defined
       
    *Test Environment*
       APPC Studio: 5.1.0.201808080937
       Google Pixel xl (Android 9)
       APPC CLI: 7.0.6
       Operating System Name: Mac OS Mojave
       Operating System Version: 10.14
       Node.js Version: 8.9.1
       Xcode 10.0
       
  6. Samir Mohammed 2018-10-16

    This works fine on Alloy Applications just not Titanium.
  7. Christopher Williams 2018-10-22

    [~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]);
               }
       }
       
    So anyways, I think if it works in Alloy then you did verify the fix.

JSON Source