Skip to content

Commit 2816df2

Browse files
committed
An active element should not remain active once a pinch-to-zoom gesture starts #1654
The issue doesn't seem to be reproducible with this change.
1 parent 7b51488 commit 2816df2

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

src/extensions/renderer/base/load-listeners.js

+30-18
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,6 @@ BRp.load = function(){
11601160
type: 'cxttapstart',
11611161
cyPosition: { x: now[0], y: now[1] }
11621162
} ) );
1163-
r.touchData.start = null;
11641163
}
11651164

11661165
if( r.touchData.start ){ r.touchData.start._private.grabbed = false; }
@@ -1235,14 +1234,6 @@ BRp.load = function(){
12351234
// Tap, taphold
12361235
// -----
12371236

1238-
r.touchData.startPosition = [];
1239-
for (var i=0; i<now.length; i++) {
1240-
earlier[i] = now[i];
1241-
r.touchData.startPosition[i] = now[i];
1242-
}
1243-
1244-
r.touchData.startGPosition = [ e.touches[0].clientX, e.touches[0].clientY ];
1245-
12461237
r.touchData.singleTouchMoved = false;
12471238
r.touchData.singleTouchStartTime = +new Date();
12481239

@@ -1265,6 +1256,18 @@ BRp.load = function(){
12651256
}, r.tapholdDuration );
12661257
}
12671258

1259+
if( e.touches.length >= 1 ){
1260+
var sPos = r.touchData.startPosition = [];
1261+
1262+
for( var i = 0; i < now.length; i++ ){
1263+
sPos[i] = earlier[i] = now[i];
1264+
}
1265+
1266+
var touch0 = e.touches[0];
1267+
1268+
r.touchData.startGPosition = [ touch0.clientX, touch0.clientY ];
1269+
}
1270+
12681271
}, false );
12691272

12701273
var touchmoveHandler;
@@ -1283,11 +1286,11 @@ BRp.load = function(){
12831286
if( e.touches[1] ){ var pos = r.projectIntoViewport( e.touches[1].clientX, e.touches[1].clientY ); now[2] = pos[0]; now[3] = pos[1]; }
12841287
if( e.touches[2] ){ var pos = r.projectIntoViewport( e.touches[2].clientX, e.touches[2].clientY ); now[4] = pos[0]; now[5] = pos[1]; }
12851288

1289+
var startGPos = r.touchData.startGPosition;
12861290
var isOverThresholdDrag;
12871291

1288-
if( capture && e.touches[0] ){
1292+
if( capture && e.touches[0] && startGPos ){
12891293
var disp = []; for (var j=0;j<now.length;j++) { disp[j] = now[j] - earlier[j]; }
1290-
var startGPos = r.touchData.startGPosition;
12911294
var dx = e.touches[0].clientX - startGPos[0];
12921295
var dx2 = dx * dx;
12931296
var dy = e.touches[0].clientY - startGPos[1];
@@ -1315,16 +1318,23 @@ BRp.load = function(){
13151318
// cancel ctx gestures if the distance b/t the fingers increases
13161319
if( factorSq >= factorThresholdSq || distance2Sq >= distThresholdSq ){
13171320
r.touchData.cxt = false;
1318-
if( r.touchData.start ){ r.touchData.start.unactivate(); r.touchData.start = null; }
1321+
13191322
r.data.bgActivePosistion = undefined;
1323+
13201324
r.redrawHint( 'select', true );
13211325

13221326
var cxtEvt = new Event( e, {
13231327
type: 'cxttapend',
13241328
cyPosition: { x: now[0], y: now[1] }
13251329
} );
1330+
13261331
if( r.touchData.start ){
1327-
r.touchData.start.trigger( cxtEvt );
1332+
r.touchData.start
1333+
.unactivate()
1334+
.trigger( cxtEvt )
1335+
;
1336+
1337+
r.touchData.start = null;
13281338
} else {
13291339
cy.trigger( cxtEvt );
13301340
}
@@ -1416,8 +1426,10 @@ BRp.load = function(){
14161426
r.redrawHint( 'drag', true );
14171427

14181428
for( var i = 0; i < draggedEles.length; i++ ){
1419-
draggedEles[ i ]._private.grabbed = false;
1420-
draggedEles[ i ]._private.rscratch.inDragLayer = false;
1429+
var de_p = draggedEles[i]._private;
1430+
1431+
de_p.grabbed = false;
1432+
de_p.rscratch.inDragLayer = false;
14211433
}
14221434
}
14231435

@@ -1431,7 +1443,7 @@ BRp.load = function(){
14311443
// var factor = Math.sqrt( distance2Sq ) / Math.sqrt( distance1Sq );
14321444
var factor = distance2 / distance1;
14331445

1434-
if( factor != 1 && twoFingersStartInside ){
1446+
if( twoFingersStartInside ){
14351447
// delta finger1
14361448
var df1x = f1x2 - f1x1;
14371449
var df1y = f1y2 - f1y1;
@@ -1468,7 +1480,7 @@ BRp.load = function(){
14681480
};
14691481

14701482
// remove dragged eles
1471-
if( r.touchData.start ){
1483+
if( r.touchData.start && r.touchData.start.active() ){
14721484
var draggedEles = r.dragData.touchDragEles;
14731485

14741486
freeDraggedElements( draggedEles );
@@ -1477,8 +1489,8 @@ BRp.load = function(){
14771489
r.redrawHint( 'eles', true );
14781490

14791491
r.touchData.start
1480-
.trigger( 'free' )
14811492
.unactivate()
1493+
.trigger( 'free' )
14821494
;
14831495
}
14841496

0 commit comments

Comments
 (0)