Remove unused functionality in fabric.Image (maxwidth/maxheight). If we do add this in the future, it should really be on fabric.Object not only on fabric.Image.

This commit is contained in:
kangax 2012-02-10 00:13:09 -05:00
parent c31603e88a
commit 905ab44665

View file

@ -26,18 +26,6 @@
*/
fabric.Image = fabric.util.createClass(fabric.Object, /** @scope fabric.Image.prototype */ {
/**
* @property
* @type Number
*/
maxwidth: null,
/**
* @property
* @type Number
*/
maxheight: null,
/**
* @property
* @type Boolean
@ -110,41 +98,6 @@
return this;
},
/**
* Resizes an image depending on whether maxwidth and maxheight are set up;
* Width and height have to mantain the same proportion in the final image as it was in the initial one.
* @method getNormalizedSize
* @param {Object} oImg
* @param {Number} maxwidth maximum width of the image (in px)
* @param {Number} maxheight maximum height of the image (in px)
*/
getNormalizedSize: function(oImg, maxwidth, maxheight) {
if (maxheight && maxwidth && (oImg.width > oImg.height && (oImg.width / oImg.height) < (maxwidth / maxheight))) {
// height is the constraining dimension.
normalizedWidth = ~~((oImg.width * maxheight) / oImg.height);
normalizedHeight = maxheight;
}
else if (maxheight && ((oImg.height == oImg.width) || (oImg.height > oImg.width) || (oImg.height > maxheight))) {
// height is the constraining dimension.
normalizedWidth = ~~((oImg.width * maxheight) / oImg.height);
normalizedHeight = maxheight;
}
else if (maxwidth && (maxwidth < oImg.width)) {
// width is the constraining dimension.
normalizedHeight = ~~((oImg.height * maxwidth) / oImg.width);
normalizedWidth = maxwidth;
}
else {
normalizedWidth = oImg.width;
normalizedHeight = oImg.height;
}
return {
width: normalizedWidth,
height: normalizedHeight
};
},
/**
* Returns original size of an image
* @method getOriginalSize