Comparing version 4.0.0-beta.8-browser to 4.0.0-beta.9-browser
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ | ||
var fabric = fabric || { version: '4.0.0-beta.8' }; | ||
var fabric = fabric || { version: '4.0.0-beta.9' }; | ||
if (typeof exports !== 'undefined') { | ||
@@ -5,0 +5,0 @@ exports.fabric = fabric; |
@@ -5,3 +5,3 @@ { | ||
"homepage": "http://fabricjs.com/", | ||
"version": "4.0.0-beta.8-browser", | ||
"version": "4.0.0-beta.9-browser", | ||
"author": "Juriy Zaytsev <kangax@gmail.com>", | ||
@@ -8,0 +8,0 @@ "contributors": [ |
@@ -6,3 +6,3 @@ (function(global) { | ||
var fabric = global.fabric || (global.fabric = { }), | ||
degreesToRadians = fabric.util.degreesToRadians, | ||
util = fabric.util, | ||
renderCircleControl = fabric.controlRenderers.renderCircleControl, | ||
@@ -180,5 +180,10 @@ renderSquareControl = fabric.controlRenderers.renderSquareControl; | ||
* @param {fabric.Object} object on which the control is displayed | ||
* @param {String} controlKey key where the control is memorized on the | ||
* @return {Boolean} | ||
*/ | ||
getVisibility: function(/*fabricObject */) { | ||
getVisibility: function(fabricObject, controlKey) { | ||
var objectVisibility = fabricObject._controlsVisibility; | ||
if (objectVisibility && typeof objectVisibility[controlKey] !== 'undefined') { | ||
return objectVisibility[controlKey]; | ||
} | ||
return this.visible; | ||
@@ -198,25 +203,24 @@ }, | ||
positionHandler: function(dim, finalMatrix, fabricObject /* currentControl */ ) { | ||
var padding = fabricObject.padding, angle = degreesToRadians(fabricObject.angle), | ||
cos = fabric.util.cos(angle), sin = fabric.util.sin(angle), offsetX = this.offsetX, | ||
var padding = fabricObject.padding, angle = util.degreesToRadians(fabricObject.angle), | ||
cos = util.cos(angle), sin = util.sin(angle), offsetX = this.offsetX, | ||
offsetY = this.offsetY, cosP = cos * padding, sinP = sin * padding, cosY = cos * offsetY, | ||
cosX = cos * offsetX, sinY = sin * offsetY, sinX = sin * offsetX, | ||
point = fabric.util.transformPoint({ | ||
x: (this.x * dim.x), | ||
y: (this.y * dim.y) }, finalMatrix); | ||
point = util.transformPoint({ | ||
x: this.x * dim.x, | ||
y: this.y * dim.y }, finalMatrix); | ||
if (this.x > 0) { | ||
point.x += cosP + cosX - sinY; | ||
point.y += sinP + sinX + cosY; | ||
point.x += cosP + cosX - sinY; | ||
} | ||
if (this.x < 0) { | ||
point.x += -cosP + cosX - sinY; | ||
point.y += -sinP + sinX + cosY; | ||
} | ||
if (this.y > 0) { | ||
point.x += -sinP + cosX - sinY; | ||
point.y += cosP + sinX + cosY; | ||
point.x += -sinP + cosX - sinY; | ||
} | ||
// to be verified | ||
if (this.x < 0) { | ||
point.y += -sinP - sinX - cosY; | ||
point.x += -cosP - cosX + sinY; | ||
} | ||
if (this.y < 0) { | ||
point.x += sinP + cosX - sinY; | ||
point.y += -cosP - sinX + cosY; | ||
point.x += sinP + cosX - sinY; | ||
} | ||
@@ -241,5 +245,2 @@ return point; | ||
styleOverride = styleOverride || {}; | ||
if (!this.getVisibility(fabricObject)) { | ||
return; | ||
} | ||
switch (styleOverride.cornerStyle || fabricObject.cornerStyle) { | ||
@@ -246,0 +247,0 @@ case 'circle': |
@@ -125,4 +125,6 @@ (function(global) { | ||
function getLocalPoint(target, originX, originY, x, y) { | ||
var zoom = target.canvas.getZoom(), | ||
function getLocalPoint(transform, originX, originY, x, y) { | ||
var target = transform.target, | ||
control = target.controls[transform.corner], | ||
zoom = target.canvas.getZoom(), | ||
padding = target.padding / zoom, | ||
@@ -142,2 +144,4 @@ localPoint = target.toLocalPoint(new fabric.Point(x, y), originX, originY); | ||
} | ||
localPoint.x -= control.offsetX; | ||
localPoint.y -= control.offsetY; | ||
return localPoint; | ||
@@ -162,3 +166,3 @@ } | ||
dimNoSkew = target._getTransformedDimensions(0, target.skewY), | ||
localPoint = getLocalPoint(target, transform.originX, transform.originY, x, y), | ||
localPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y), | ||
// the mouse is in the center of the object, and we want it to stay there. | ||
@@ -174,3 +178,3 @@ // so the object will grow twice as much as the mouse. | ||
else { | ||
newSkew = fabric.util.radiansToDegrees( | ||
newSkew = radiansToDegrees( | ||
Math.atan2((totalSkewSize / target.scaleX), (dimNoSkew.y / target.scaleY)) | ||
@@ -204,3 +208,3 @@ ); | ||
dimNoSkew = target._getTransformedDimensions(target.skewX, 0), | ||
localPoint = getLocalPoint(target, transform.originX, transform.originY, x, y), | ||
localPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y), | ||
// the mouse is in the center of the object, and we want it to stay there. | ||
@@ -216,3 +220,3 @@ // so the object will grow twice as much as the mouse. | ||
else { | ||
newSkew = fabric.util.radiansToDegrees( | ||
newSkew = radiansToDegrees( | ||
Math.atan2((totalSkewSize / target.scaleY), (dimNoSkew.x / target.scaleX)) | ||
@@ -255,3 +259,3 @@ ); | ||
if (currentSkew === 0) { | ||
var localPointFromCenter = getLocalPoint(target, CENTER, CENTER, x, y); | ||
var localPointFromCenter = getLocalPoint(transform, CENTER, CENTER, x, y); | ||
if (localPointFromCenter.x > 0) { | ||
@@ -298,3 +302,3 @@ // we are pulling right, anchor left; | ||
if (currentSkew === 0) { | ||
var localPointFromCenter = getLocalPoint(target, CENTER, CENTER, x, y); | ||
var localPointFromCenter = getLocalPoint(transform, CENTER, CENTER, x, y); | ||
if (localPointFromCenter.y > 0) { | ||
@@ -384,3 +388,3 @@ // we are pulling down, anchor up; | ||
dim = target._getTransformedDimensions(); | ||
newPoint = getLocalPoint(target, transform.originX, transform.originY, x, y); | ||
newPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y); | ||
@@ -455,3 +459,3 @@ // missing detection of flip and logic to switch the origin | ||
function changeWidth(eventData, transform, x, y) { | ||
var target = transform.target, localPoint = getLocalPoint(target, transform.originX, transform.originY, x, y), | ||
var target = transform.target, localPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y), | ||
strokePadding = target.strokeWidth / (target.strokeUniform ? target.scaleX : 1), | ||
@@ -458,0 +462,0 @@ newWidth = Math.abs(localPoint.x / target.scaleX) - strokePadding; |
@@ -11,5 +11,2 @@ (function(global) { | ||
styleOverride = styleOverride || {}; | ||
if (!this.getVisibility(fabricObject)) { | ||
return; | ||
} | ||
var size = styleOverride.cornerSize || fabricObject.cornerSize, | ||
@@ -36,5 +33,2 @@ transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? | ||
styleOverride = styleOverride || {}; | ||
if (!this.getVisibility(fabricObject)) { | ||
return; | ||
} | ||
var size = styleOverride.cornerSize || fabricObject.cornerSize, | ||
@@ -41,0 +35,0 @@ transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? |
@@ -6,3 +6,2 @@ (function() { | ||
fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { | ||
/** | ||
@@ -197,3 +196,3 @@ * Determines which corner has been clicked | ||
// width and height of the above function are the size of the bbox. | ||
if (control.withConnection && control.getVisibility(fabricObject)) { | ||
if (control.withConnection && control.getVisibility(fabricObject, key)) { | ||
// reset movement for each control | ||
@@ -275,8 +274,9 @@ shouldStroke = true; | ||
this.setCoords(false); | ||
for (var c in this.controls) { | ||
this.controls[c].render(ctx, | ||
this.oCoords[c].x, | ||
this.oCoords[c].y, styleOverride, this); | ||
} | ||
this.forEachControl(function(control, key, fabricObject) { | ||
if (control.getVisibility(fabricObject, key)) { | ||
control.render(ctx, | ||
fabricObject.oCoords[key].x, | ||
fabricObject.oCoords[key].y, styleOverride, fabricObject); | ||
} | ||
}); | ||
ctx.restore(); | ||
@@ -293,3 +293,3 @@ | ||
isControlVisible: function(controlKey) { | ||
return this.controls[controlKey] && this.controls[controlKey].getVisibility(this); | ||
return this.controls[controlKey] && this.controls[controlKey].getVisibility(this, controlKey); | ||
}, | ||
@@ -305,3 +305,6 @@ | ||
setControlVisible: function(controlKey, visible) { | ||
this.controls[controlKey].setVisibility(visible, this, controlKey); | ||
if (!this._controlsVisibility) { | ||
this._controlsVisibility = {}; | ||
} | ||
this._controlsVisibility[controlKey] = visible; | ||
return this; | ||
@@ -334,14 +337,2 @@ }, | ||
/** | ||
* Returns the instance of the control visibility set for this object. | ||
* @private | ||
* @returns {Object} | ||
*/ | ||
_getControlsVisibility: function() { | ||
var visibility = {}; | ||
this.forEachControl(function(control, key, fabricObject) { | ||
visibility[key] = control.getVisibility(fabricObject); | ||
}); | ||
return visibility; | ||
}, | ||
@@ -348,0 +339,0 @@ /** |
@@ -137,3 +137,3 @@ (function(global) { | ||
} | ||
else if (attr === 'href' || attr === 'xlink:href') { | ||
else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') { | ||
return value; | ||
@@ -140,0 +140,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2411917
56637