cytoscape-canvas-underlay 1.3.0 → 1.3.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cytoscape-canvas-underlay",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Cytoscape.js plugin for rendering image/PDF canvas underlay behind graph nodes with synchronized zoom and pan",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -207,6 +207,9 @@ export class DrawingOverlay {
207
207
  // Additional drawings
208
208
  this._drawings = new Map();
209
209
 
210
+ // PDF 존재 여부 캐시 (zoom/pan마다 순회 방지)
211
+ this._hasPdfCached = false;
212
+
210
213
  // RAF / debounce
211
214
  this._rafId = null;
212
215
  this._qualityTimer = null;
@@ -297,7 +300,7 @@ export class DrawingOverlay {
297
300
  if (this._minimap) this._minimap.render();
298
301
 
299
302
  // Schedule high-quality PDF re-render at current zoom level
300
- const hasPdf = this._main.isPdf || [...this._drawings.values()].some(d => d.isPdf && d.visible);
303
+ const hasPdf = this._hasPdfCached;
301
304
  if (hasPdf) {
302
305
  if (this._qualityTimer) clearTimeout(this._qualityTimer);
303
306
  this._qualityTimer = setTimeout(() => {
@@ -649,6 +652,7 @@ export class DrawingOverlay {
649
652
  }
650
653
  }
651
654
  this._loading = false;
655
+ this._updateHasPdf();
652
656
 
653
657
  if (this.opts.fitOnLoad) this.fit();
654
658
  this._draw();
@@ -891,6 +895,16 @@ export class DrawingOverlay {
891
895
  Public API: Utility
892
896
  ═══════════════════════════════════════ */
893
897
 
898
+ /** PDF 존재 여부 캐시 갱신 */
899
+ _updateHasPdf() {
900
+ this._hasPdfCached = this._main.isPdf;
901
+ if (!this._hasPdfCached) {
902
+ for (const d of this._drawings.values()) {
903
+ if (d.isPdf && d.visible) { this._hasPdfCached = true; break; }
904
+ }
905
+ }
906
+ }
907
+
894
908
  /** Force redraw. */
895
909
  refresh() {
896
910
  this._setupCanvas();
@@ -1044,6 +1058,7 @@ export class DrawingOverlay {
1044
1058
  }
1045
1059
 
1046
1060
  this._drawings.set(id, state);
1061
+ this._updateHasPdf();
1047
1062
  this._draw();
1048
1063
  this._emit('drawingAdd', id, { x: state.x, y: state.y, width: state.width, height: state.height });
1049
1064
  }
@@ -1059,6 +1074,7 @@ export class DrawingOverlay {
1059
1074
  const state = this._drawings.get(id);
1060
1075
  if (!state) return;
1061
1076
  state.visible = visible;
1077
+ if (state.isPdf) this._updateHasPdf();
1062
1078
  this._draw();
1063
1079
  }
1064
1080
 
@@ -1069,12 +1085,14 @@ export class DrawingOverlay {
1069
1085
 
1070
1086
  removeDrawing(id) {
1071
1087
  this._drawings.delete(id);
1088
+ this._updateHasPdf();
1072
1089
  this._draw();
1073
1090
  this._emit('drawingRemove', id);
1074
1091
  }
1075
1092
 
1076
1093
  clearDrawings() {
1077
1094
  this._drawings.clear();
1095
+ this._updateHasPdf();
1078
1096
  this._draw();
1079
1097
  }
1080
1098