@stocksharp/diagram 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1635,15 +1635,21 @@ export class Diagram {
1635
1635
  resize(w, h) {
1636
1636
  if (w < 2 || h < 2)
1637
1637
  return;
1638
+ const dpr = window.devicePixelRatio || 1;
1639
+ // Setting a canvas's size clears it, even to the size it has: a size it already has is left alone.
1640
+ if (w === this.width && h === this.height && dpr === this.dpr)
1641
+ return;
1638
1642
  this.width = w;
1639
1643
  this.height = h;
1640
- this.dpr = window.devicePixelRatio || 1;
1644
+ this.dpr = dpr;
1641
1645
  this.canvas.width = Math.round(w * this.dpr);
1642
1646
  this.canvas.height = Math.round(h * this.dpr);
1643
1647
  this.canvas.style.width = `${w}px`;
1644
1648
  this.canvas.style.height = `${h}px`;
1645
1649
  this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
1646
- this.scheduleDraw();
1650
+ // Drawn now, not on the next frame: the frame being laid out would otherwise show the cleared canvas.
1651
+ if (!this.destroyed)
1652
+ this.draw();
1647
1653
  }
1648
1654
  getInteractionPermissions() {
1649
1655
  return { ...this.permissions };