Skip to content

Commit

Permalink
Merge pull request #1405 from martinRenou/do_not_relayout_unneeded
Browse files Browse the repository at this point in the history
Speedup: Do not relayout if not needed
  • Loading branch information
martinRenou committed Sep 30, 2021
2 parents 96b0b93 + 0b49ede commit 645aa4f
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 @@ -759,13 +759,7 @@ export class Figure extends 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 @@ -775,6 +769,12 @@ export class Figure extends 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 645aa4f

Please sign in to comment.