Skip to content

Commit

Permalink
Merge pull request #1411 from meeseeksmachine/auto-backport-of-pr-140…
Browse files Browse the repository at this point in the history
…5-on-0.12.x

Backport PR #1405 on branch 0.12.x (Speedup: Do not relayout if not needed)
  • Loading branch information
martinRenou committed Oct 1, 2021
2 parents fe112ff + 9c930c3 commit 27ee7ed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions js/src/Figure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,7 @@ export class Figure extends widgets.DOMWidgetView {
case 'after-show':
case 'after-attach':
if (this.pWidget.isVisible) {
const figureSize = this.getFigureSize();
if (
this.width !== figureSize.width ||
this.height !== figureSize.height
) {
this.debouncedRelayout();
}
this.debouncedRelayout();
}
break;
}
Expand All @@ -755,6 +749,12 @@ export class Figure extends widgets.DOMWidgetView {
const relayoutImpl = () => {
this.relayoutRequested = false; // reset relayout request
const figureSize = this.getFigureSize();

if (this.width == figureSize.width && this.height == figureSize.height) {
// Bypass relayout
return;
}

this.width = figureSize.width;
this.height = figureSize.height;
// update ranges
Expand Down

0 comments on commit 27ee7ed

Please sign in to comment.