Use operators instead of Math.max/min

This commit is contained in:
Tom Payne
2013-03-22 19:27:52 +01:00
parent 876fea2fb7
commit 24452b0bcb
+24 -8
View File
@@ -52,10 +52,18 @@ ol.Rectangle.prototype.equals = function(rectangle) {
* @param {ol.Rectangle} rectangle Rectangle. * @param {ol.Rectangle} rectangle Rectangle.
*/ */
ol.Rectangle.prototype.extend = function(rectangle) { ol.Rectangle.prototype.extend = function(rectangle) {
this.minX = Math.min(this.minX, rectangle.minX); if (rectangle.minX < this.minX) {
this.minY = Math.min(this.minY, rectangle.minY); this.minX = rectangle.minX;
this.maxX = Math.max(this.maxX, rectangle.maxX); }
this.maxY = Math.max(this.maxY, rectangle.maxY); if (rectangle.minY < this.minY) {
this.minY = rectangle.minY;
}
if (rectangle.maxX > this.maxX) {
this.maxX = rectangle.maxX;
}
if (rectangle.maxY > this.maxY) {
this.maxY = rectangle.maxY;
}
}; };
@@ -64,10 +72,18 @@ ol.Rectangle.prototype.extend = function(rectangle) {
* @param {number} y Y. * @param {number} y Y.
*/ */
ol.Rectangle.prototype.extendXY = function(x, y) { ol.Rectangle.prototype.extendXY = function(x, y) {
this.minX = Math.min(this.minX, x); if (x < this.minX) {
this.minY = Math.min(this.minY, y); this.minX = x;
this.maxX = Math.max(this.maxX, x); }
this.maxY = Math.max(this.maxY, y); if (y < this.minY) {
this.minY = y;
}
if (x > this.maxX) {
this.maxX = x;
}
if (y > this.maxY) {
this.maxY = y;
}
}; };