@ngroznykh/papirus 0.3.14 → 0.3.15

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/README.md CHANGED
@@ -160,7 +160,7 @@ await svgExporter.download('diagram.svg');
160
160
  import { GridOverlay, MiniMap } from '@ngroznykh/papirus';
161
161
 
162
162
  renderer.use(new GridOverlay({ gridSize: 20 }));
163
- renderer.use(new MiniMap({ width: 180, height: 120, padding: 12 }));
163
+ renderer.use(new MiniMap({ width: 180, height: 120, padding: 12, contentMargin: 200 }));
164
164
  ```
165
165
 
166
166
  Also available: `RulersOverlay`, `GuidesOverlay`, `AutoLayout`, `AutoRouting`, `alignNodes`, `distributeNodes`.
package/README.ru.md CHANGED
@@ -161,7 +161,7 @@ await svgExporter.download('diagram.svg');
161
161
  import { GridOverlay, MiniMap } from '@ngroznykh/papirus';
162
162
 
163
163
  renderer.use(new GridOverlay({ gridSize: 20 }));
164
- renderer.use(new MiniMap({ width: 180, height: 120, padding: 12 }));
164
+ renderer.use(new MiniMap({ width: 180, height: 120, padding: 12, contentMargin: 200 }));
165
165
  ```
166
166
 
167
167
  Доступны также `RulersOverlay`, `GuidesOverlay`, `AutoLayout`, `AutoRouting`, `alignNodes`, `distributeNodes`.
@@ -5,6 +5,8 @@ export interface MiniMapOptions {
5
5
  width?: number;
6
6
  height?: number;
7
7
  padding?: number;
8
+ /** Отступ (в мировых координатах) вокруг контента — расширяет область, в пределах которой можно перемещать view. По умолчанию 0. */
9
+ contentMargin?: number;
8
10
  backgroundColor?: string;
9
11
  borderColor?: string;
10
12
  viewportColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"MiniMap.d.ts","sourceRoot":"","sources":["../../../src/core/overlays/MiniMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIzE,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,WAAW,G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cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oIAAoI;IACpI,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAeD,UAAU,kBAAkB;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,OAAQ,YAAW,aAAa;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,aAAa,CAA6B;gBAEtC,OAAO,GAAE,cAAmB;IAcxC,OAAO,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAiExC,OAAO,IAAI,IAAI;IAKf,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC,gBAAgB,CACd,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,kBAAkB,GAAG,IAAI;IA4B5B,iBAAiB,CACf,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,GACf,OAAO;IA0CV,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,aAAa;CAyFtB"}
package/dist/papirus.js CHANGED
@@ -10937,6 +10937,7 @@ class MiniMap {
10937
10937
  width: options.width ?? 180,
10938
10938
  height: options.height ?? 120,
10939
10939
  padding: options.padding ?? 12,
10940
+ contentMargin: options.contentMargin ?? 0,
10940
10941
  backgroundColor: options.backgroundColor ?? "rgba(24, 24, 27, 0.5)",
10941
10942
  borderColor: options.borderColor ?? "#52525b",
10942
10943
  viewportColor: options.viewportColor ?? "#22c55e",
@@ -11075,14 +11076,27 @@ class MiniMap {
11075
11076
  if (!rawBounds) {
11076
11077
  return null;
11077
11078
  }
11079
+ const margin = this.options.contentMargin;
11080
+ const expandedContentBounds = {
11081
+ x: rawBounds.x - margin,
11082
+ y: rawBounds.y - margin,
11083
+ width: rawBounds.width + 2 * margin,
11084
+ height: rawBounds.height + 2 * margin
11085
+ };
11078
11086
  const { width, height, padding, anchor } = this.options;
11079
11087
  const x = anchor === "bottom-left" || anchor === "top-left" ? padding : renderer.width - width - padding;
11080
11088
  const y = anchor === "top-left" || anchor === "top-right" ? padding : renderer.height - height - padding;
11081
11089
  const viewportBounds = this.getViewportBounds(renderer);
11082
- const unionMinX = Math.min(rawBounds.x, viewportBounds.x);
11083
- const unionMinY = Math.min(rawBounds.y, viewportBounds.y);
11084
- const unionMaxX = Math.max(rawBounds.x + rawBounds.width, viewportBounds.x + viewportBounds.width);
11085
- const unionMaxY = Math.max(rawBounds.y + rawBounds.height, viewportBounds.y + viewportBounds.height);
11090
+ const unionMinX = Math.min(expandedContentBounds.x, viewportBounds.x);
11091
+ const unionMinY = Math.min(expandedContentBounds.y, viewportBounds.y);
11092
+ const unionMaxX = Math.max(
11093
+ expandedContentBounds.x + expandedContentBounds.width,
11094
+ viewportBounds.x + viewportBounds.width
11095
+ );
11096
+ const unionMaxY = Math.max(
11097
+ expandedContentBounds.y + expandedContentBounds.height,
11098
+ viewportBounds.y + viewportBounds.height
11099
+ );
11086
11100
  const bounds = {
11087
11101
  x: unionMinX,
11088
11102
  y: unionMinY,