pure-canvas
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -25,16 +25,22 @@ "use strict"; | ||
}; | ||
LayerCached.prototype.invalidateBounds = function () { | ||
this.cachedBounds = undefined; | ||
}; | ||
LayerCached.prototype.getBounds = function () { | ||
if (this.clipRegion) { | ||
var _a = this.clipRegion, clipMinX = _a.minX, clipMinY = _a.minY, clipMaxX = _a.maxX, clipMaxY = _a.maxY; | ||
var _b = _super.prototype.getBounds.call(this), minX = _b.minX, minY = _b.minY, maxX = _b.maxX, maxY = _b.maxY; | ||
return { | ||
minX: Math.max(minX, clipMinX), | ||
minY: Math.max(minY, clipMinY), | ||
maxX: Math.min(maxX, clipMaxX), | ||
maxY: Math.min(maxY, clipMaxY) | ||
}; | ||
if (!this.cachedBounds) { | ||
if (this.clipRegion) { | ||
var _a = this.clipRegion, clipMinX = _a.minX, clipMinY = _a.minY, clipMaxX = _a.maxX, clipMaxY = _a.maxY; | ||
var _b = _super.prototype.getBounds.call(this), minX = _b.minX, minY = _b.minY, maxX = _b.maxX, maxY = _b.maxY; | ||
this.cachedBounds = { | ||
minX: Math.max(minX, clipMinX), | ||
minY: Math.max(minY, clipMinY), | ||
maxX: Math.min(maxX, clipMaxX), | ||
maxY: Math.min(maxY, clipMaxY) | ||
}; | ||
} | ||
else { | ||
this.cachedBounds = _super.prototype.getBounds.call(this); | ||
} | ||
} | ||
else { | ||
return _super.prototype.getBounds.call(this); | ||
} | ||
return this.cachedBounds; | ||
}; | ||
@@ -41,0 +47,0 @@ LayerCached.prototype.draw = function (context) { |
{ | ||
"name": "pure-canvas", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "TODO", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -17,2 +17,4 @@ import Node, {Bounds, Point} from './Node'; | ||
private cachedBounds?: Bounds; | ||
private treeManager: TreeManager; | ||
@@ -29,19 +31,26 @@ | ||
invalidateIndex() { | ||
invalidateIndex(): void { | ||
this.treeManager = undefined; | ||
} | ||
invalidateBounds(): void { | ||
this.cachedBounds = undefined; | ||
} | ||
getBounds(): Bounds { | ||
if (this.clipRegion) { | ||
const {minX: clipMinX, minY: clipMinY, maxX: clipMaxX, maxY: clipMaxY} = this.clipRegion; | ||
const {minX, minY, maxX, maxY} = super.getBounds(); | ||
return { | ||
minX: Math.max(minX, clipMinX), | ||
minY: Math.max(minY, clipMinY), | ||
maxX: Math.min(maxX, clipMaxX), | ||
maxY: Math.min(maxY, clipMaxY) | ||
}; | ||
} else { | ||
return super.getBounds(); | ||
if (!this.cachedBounds) { | ||
if (this.clipRegion) { | ||
const {minX: clipMinX, minY: clipMinY, maxX: clipMaxX, maxY: clipMaxY} = this.clipRegion; | ||
const {minX, minY, maxX, maxY} = super.getBounds(); | ||
this.cachedBounds = { | ||
minX: Math.max(minX, clipMinX), | ||
minY: Math.max(minY, clipMinY), | ||
maxX: Math.min(maxX, clipMaxX), | ||
maxY: Math.min(maxY, clipMaxY) | ||
}; | ||
} else { | ||
this.cachedBounds = super.getBounds(); | ||
} | ||
} | ||
return this.cachedBounds; | ||
} | ||
@@ -48,0 +57,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
207240
2603