@ibodr/draw 0.1.7 → 0.1.8

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/dist/index.d.ts CHANGED
@@ -990,8 +990,6 @@ declare class CollaboratorCursorOverlayUtil extends OverlayUtil<DrCollaboratorCu
990
990
  fontSize: number;
991
991
  nameMaxWidth: number;
992
992
  chatMaxWidth: number;
993
- minCursorScale: number;
994
- maxCursorScale: number;
995
993
  };
996
994
  private _truncateCache;
997
995
  isActive(): boolean;
@@ -1040,12 +1038,26 @@ declare function mergeCollaboratorCursorLayout(overrides?: Partial<DrCollaborato
1040
1038
 
1041
1039
  /** @public */
1042
1040
  interface DrCollaboratorCursorScaleOptions {
1041
+ /**
1042
+ * When zoomed out to this level or further, cursor scale is capped at `1 / maxScaleZoom`.
1043
+ * Default: `0.5` (50%).
1044
+ */
1045
+ maxScaleZoom?: number;
1046
+ /**
1047
+ * When zoomed in to this level or further, cursor scale is floored at `1 / minScaleZoom`.
1048
+ * Default: `3` (300%).
1049
+ */
1050
+ minScaleZoom?: number;
1051
+ /** Optional absolute lower bound applied after zoom-based scaling. */
1043
1052
  minScale?: number;
1053
+ /** Optional absolute upper bound applied after zoom-based scaling. */
1044
1054
  maxScale?: number;
1045
1055
  }
1046
1056
  /**
1047
1057
  * Screen-space scale for collaborator cursors relative to camera zoom.
1048
- * Grows when zoomed out so remote cursors stay visible.
1058
+ *
1059
+ * - Zoomed out (5%–50%): scale capped at the 50% level — no further growth.
1060
+ * - Zoomed in (300%–800%): scale floored at the 300% level — no further shrink.
1049
1061
  *
1050
1062
  * @public
1051
1063
  */
package/dist/index.mjs CHANGED
@@ -20924,13 +20924,27 @@ var CollaboratorHintOverlayUtil = class extends OverlayUtil {
20924
20924
  };
20925
20925
 
20926
20926
  // src/lib/components/collaborator-cursors/getCollaboratorCursorScale.ts
20927
- var DEFAULT_MIN_CURSOR_SCALE = 0.85;
20928
- var DEFAULT_MAX_CURSOR_SCALE = 12;
20927
+ var DEFAULT_MAX_SCALE_ZOOM = 0.5;
20928
+ var DEFAULT_MIN_SCALE_ZOOM = 3;
20929
20929
  function getCollaboratorCursorScale(zoom, options = {}) {
20930
- const minScale = options.minScale ?? DEFAULT_MIN_CURSOR_SCALE;
20931
- const maxScale = options.maxScale ?? DEFAULT_MAX_CURSOR_SCALE;
20932
20930
  if (!Number.isFinite(zoom) || zoom <= 0) return 1;
20933
- return Math.min(Math.max(1 / zoom, minScale), maxScale);
20931
+ const maxScaleZoom = options.maxScaleZoom ?? DEFAULT_MAX_SCALE_ZOOM;
20932
+ const minScaleZoom = options.minScaleZoom ?? DEFAULT_MIN_SCALE_ZOOM;
20933
+ const maxScale = 1 / maxScaleZoom;
20934
+ const minScale = 1 / minScaleZoom;
20935
+ let scale = 1 / zoom;
20936
+ if (zoom <= maxScaleZoom) {
20937
+ scale = Math.min(scale, maxScale);
20938
+ } else if (zoom >= minScaleZoom) {
20939
+ scale = Math.max(scale, minScale);
20940
+ }
20941
+ if (options.minScale !== void 0) {
20942
+ scale = Math.max(scale, options.minScale);
20943
+ }
20944
+ if (options.maxScale !== void 0) {
20945
+ scale = Math.min(scale, options.maxScale);
20946
+ }
20947
+ return scale;
20934
20948
  }
20935
20949
 
20936
20950
  // src/lib/overlays/CollaboratorCursorOverlayUtil.ts
@@ -20970,9 +20984,7 @@ var CollaboratorCursorOverlayUtil = class extends OverlayUtil {
20970
20984
  zIndex: 1100,
20971
20985
  fontSize: 12,
20972
20986
  nameMaxWidth: 120,
20973
- chatMaxWidth: 200,
20974
- minCursorScale: 0.85,
20975
- maxCursorScale: 12
20987
+ chatMaxWidth: 200
20976
20988
  };
20977
20989
  // Cache truncated text results to avoid repeated measureText loops.
20978
20990
  // Key format: `${maxWidth}|${text}` with an upper bound on cache size.
@@ -21003,10 +21015,7 @@ var CollaboratorCursorOverlayUtil = class extends OverlayUtil {
21003
21015
  }
21004
21016
  render(ctx, overlays) {
21005
21017
  const zoom = this.editor.getZoomLevel();
21006
- const scale = getCollaboratorCursorScale(zoom, {
21007
- minScale: this.options.minCursorScale,
21008
- maxScale: this.options.maxCursorScale
21009
- });
21018
+ const scale = getCollaboratorCursorScale(zoom);
21010
21019
  const viewport = this.editor.getViewportPageBounds();
21011
21020
  const viewportMarginX = 12 / zoom;
21012
21021
  const viewportMarginY = 16 / zoom;
@@ -37215,7 +37224,7 @@ async function extractAssets(editor, snapshot, msg, addToast) {
37215
37224
  // src/index.ts
37216
37225
  registerDrawLibraryVersion(
37217
37226
  "@ibodr/draw",
37218
- "0.1.7",
37227
+ "0.1.8",
37219
37228
  "esm"
37220
37229
  );
37221
37230
  /*!