Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7778] iOS: The 'pinch' event listener gets fired inconsistently when used with 'touchend'

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-01-28T23:48:32.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sRelease 3.2.0
ComponentsiOS
Labelsqe-closed-3.2.3
ReporterJunaid Younus
AssigneeIngo Muschenetz
Created2012-02-22T15:54:55.000+0000
Updated2014-03-12T09:16:47.000+0000

Description

*The code*
var win = Ti.UI.createWindow({
	backgroundColor: 'gray'
});

var view = Ti.UI.createView({
	width: 320,
	height: 480,
	top: 0,
	backgroundColor: 'yellow',
	transform: Ti.UI.create2DMatrix()
});

var lastMatrix = Ti.UI.create2DMatrix();

win.addEventListener('pinch', function(e)
{
	var matrix = lastMatrix.scale(e.scale);
	view.transform = matrix;
});

win.addEventListener('touchend', function(e)
{
	win.backgroundColor = (win.backgroundColor == 'gray') ? 'red' : 'gray';
	lastMatrix = view.transform; // assign current matrix to last matrix, so it resizes view relative to the grid space instead of the screen space inside the 'pinch' event listener
});

win.add(view);

win.open();


*Expected behavior* When you pinch to zoom in/out, you should have a smooth and lag-free experience, just like on the Simulator. *Actual behavior* When you actually install this on the device, it seems to be inconsistent. Sometimes when you let go of one finger (while pinching), it fires the 'touchend' event. However other times it seems to fire only when both fingers have been let go. *Notes* -Tested using TiSDK 1.8.1, 1.8.2.v20120221114636 and 2.0.0.v20120222101634, same behavior on all three SDKs. -Tested on an iPhone 3GS and iPod Touch 4th Generation both running iOS 5.0.1 -In the official Apple docs it says (in the 'Overview' section) that both fingers should be let go off, in order to finish the pinch event: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPinchGestureRecognizer_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009283 -I assume to solve this issue a 'pinch end' event should be exposed, or maybe adjust the 'touchend' event to consider multitouch events.

Comments

  1. Junaid Younus 2012-05-18

    Issue still exists with 2.0.1GA2.
  2. Paras Mishra 2014-03-12

    Verified the fix, hence closing the issue. Environment used: Device : iPhone 5s , iOS version : 7.1 SDK: 3.2.3.v20140311115447 CLI version : 3.2.1 OS : MAC OSX 10.9 Alloy: 1.3.1 ACS: 1.0.14 npm:1.3.2 Appcelerator Studio, build: 3.2.2.201403061827 titanium-code-processor: 1.1.0 XCode : 5.1

JSON Source