Skip to content

Commit

Permalink
fix Render Bounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
jfboeve committed Mar 28, 2024
1 parent 85a5fab commit b0a3742
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ export class CoreNode extends EventEmitter implements ICoreNode {
}

if (this.updateType & UpdateType.RenderState) {
this.updateRenderState();
this.updateRenderState(parentClippingRect);
this.setUpdateType(UpdateType.IsRenderable);
}

Expand Down Expand Up @@ -574,25 +574,24 @@ export class CoreNode extends EventEmitter implements ICoreNode {
return false;
}

checkRenderBounds(): CoreNodeRenderState {
assertTruthy(this.clippingRect);
checkRenderBounds(parentClippingRect: RectWithValid): CoreNodeRenderState {
assertTruthy(this.renderBound);
const rectW = this.clippingRect.width || this.stage.root.width;
const rectH = this.clippingRect.height || this.stage.root.height;
const rectW = parentClippingRect.width || this.stage.root.width;
const rectH = parentClippingRect.height || this.stage.root.height;
this.strictBound = createBound(
this.clippingRect.x,
this.clippingRect.y,
rectW,
rectH,
parentClippingRect.x,
parentClippingRect.y,
parentClippingRect.x + rectW,
parentClippingRect.y + rectH,
this.strictBound,
);

const renderM = this.stage.boundsMargin;
this.preloadBound = createBound(
this.clippingRect.x - renderM[3],
this.clippingRect.y - renderM[0],
this.clippingRect.x + rectW + renderM[1],
this.clippingRect.y + rectH + renderM[2],
parentClippingRect.x - renderM[3],
parentClippingRect.y - renderM[0],
parentClippingRect.x + rectW + renderM[1],
parentClippingRect.y + rectH + renderM[2],
this.preloadBound,
);

Expand All @@ -606,8 +605,8 @@ export class CoreNode extends EventEmitter implements ICoreNode {
return CoreNodeRenderState.OutOfBounds;
}

updateRenderState() {
const renderState = this.checkRenderBounds();
updateRenderState(parentClippingRect: RectWithValid) {
const renderState = this.checkRenderBounds(parentClippingRect);
if (renderState !== this.renderState) {
const previous = this.renderState;
this.renderState = renderState;
Expand Down

0 comments on commit b0a3742

Please sign in to comment.