Merge pull request #2137 from jafferhaider/Issue510PullRequest

Added missing events in multi-touch gestures. Closes #510
This commit is contained in:
Juriy Zaytsev 2015-04-22 15:07:23 +02:00
commit 46cd6ab505

View file

@ -48,23 +48,23 @@
}
var self = this.__gesturesParams.self,
t = this._currentTransform;
t = this._currentTransform,
e = this.__gesturesParams.e;
t.action = 'scale';
t.originX = t.originY = 'center';
this._setOriginToCenter(t.target);
this._scaleObjectBy(self.scale);
this._scaleObjectBy(self.scale, e);
if (self.rotation !== 0) {
t.action = 'rotate';
this._rotateObjectByAngle(self.rotation);
this._rotateObjectByAngle(self.rotation, e);
}
this.renderAll();
t.action = 'drag';
},
/**
* Method that defines actions when an Event.js drag is detected.
*
@ -76,7 +76,6 @@
e: e, self: self
});
},
/**
* Method that defines actions when an Event.js orientation event is detected.
*
@ -88,7 +87,6 @@
e: e, self: self
});
},
/**
* Method that defines actions when an Event.js shake event is detected.
*
@ -100,7 +98,6 @@
e: e, self: self
});
},
/**
* Method that defines actions when an Event.js longpress event is detected.
*
@ -112,14 +109,12 @@
e: e, self: self
});
},
/**
* Scales an object by a factor
* @param {Number} s The scale factor to apply to the current scale level
* @param {String} by Either 'x' or 'y' - specifies dimension constraint by which to scale an object.
* When not provided, an object is scaled by both dimensions equally
* @param {Event} e Event object by Event.js
*/
_scaleObjectBy: function(s, by) {
_scaleObjectBy: function(s, e) {
var t = this._currentTransform,
target = t.target,
lockScalingX = target.get('lockScalingX'),
@ -131,33 +126,30 @@
target._scaling = true;
var constraintPosition = target.translateToOriginPoint(target.getCenterPoint(), t.originX, t.originY);
var constraintPosition = target.translateToOriginPoint(target.getCenterPoint(), t.originX, t.originY),
halfStrokeWidth = target.stroke ? target.strokeWidth / 2 : 0;
if (!by) {
t.newScaleX = t.scaleX * s;
t.newScaleY = t.scaleY * s;
if (!lockScalingX) {
target.set('scaleX', t.scaleX * s);
}
if (!lockScalingY) {
target.set('scaleY', t.scaleY * s);
}
}
this._setObjectScale(new fabric.Point((t.scaleX * s * (target.width + halfStrokeWidth)),
(t.scaleY * s * (target.height + halfStrokeWidth))),
t, lockScalingX, lockScalingY, null, target.get('lockScalingFlip'));
target.setPositionByOrigin(constraintPosition, t.originX, t.originY);
},
this._fire('scaling', target, e);
},
/**
* Rotates object by an angle
* @param {Number} curAngle The angle of rotation in degrees
* @param {Event} e Event object by Event.js
*/
_rotateObjectByAngle: function(curAngle) {
_rotateObjectByAngle: function(curAngle, e) {
var t = this._currentTransform;
if (t.target.get('lockRotation')) {
return;
}
t.target.angle = radiansToDegrees(degreesToRadians(curAngle) + t.theta);
this._fire('rotating', t.target, e);
}
});
})();