@leapfrog/interactive-canvas 1.0.7 → 1.1.0

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.
@@ -0,0 +1,15 @@
1
+ import { ICanvasDimensions } from "..";
2
+ export declare class MillimeterDimensions implements ICanvasDimensions {
3
+ readonly width: number;
4
+ readonly widthPx: number;
5
+ readonly widthMm: number;
6
+ readonly widthUnit: string;
7
+ readonly height: number;
8
+ readonly heightPx: number;
9
+ readonly heightMm: number;
10
+ readonly heightUnit: string;
11
+ constructor(width: number, height: number);
12
+ withSize(width: number, height: number): ICanvasDimensions;
13
+ widthPxToMm(px: number): number | undefined;
14
+ heightPxToMm(px: number): number | undefined;
15
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./dimensions/millimeter-dimensions";
1
2
  export * from "./dimensions/pixel-canvas-dimensions";
2
3
  export * from "./dimensions/print-6-col-canvas-dimensions";
3
4
  export * from "./dimensions/print-8-col-canvas-dimensions";
@@ -4,6 +4,30 @@ import { oc } from 'ts-optchain';
4
4
  import { BehaviorSubject, Subject } from 'rxjs';
5
5
  import { fabric } from 'fabric';
6
6
 
7
+ var PIXELS_PER_MM = 3.937;
8
+ var MillimeterDimensions = /** @class */ (function () {
9
+ function MillimeterDimensions(width, height) {
10
+ this.widthUnit = "mm";
11
+ this.heightUnit = "mm";
12
+ this.width = width;
13
+ this.widthMm = Math.max(0, width);
14
+ this.widthPx = round(this.widthMm * PIXELS_PER_MM);
15
+ this.height = height;
16
+ this.heightMm = Math.max(0, height);
17
+ this.heightPx = round(this.heightMm * PIXELS_PER_MM);
18
+ }
19
+ MillimeterDimensions.prototype.withSize = function (width, height) {
20
+ return new MillimeterDimensions(width, height);
21
+ };
22
+ MillimeterDimensions.prototype.widthPxToMm = function (px) {
23
+ return px / PIXELS_PER_MM;
24
+ };
25
+ MillimeterDimensions.prototype.heightPxToMm = function (px) {
26
+ return px / PIXELS_PER_MM;
27
+ };
28
+ return MillimeterDimensions;
29
+ }());
30
+
7
31
  var PixelCanvasDimensions = /** @class */ (function () {
8
32
  function PixelCanvasDimensions(width, height) {
9
33
  this.widthUnit = "px";
@@ -27,7 +51,7 @@ var PixelCanvasDimensions = /** @class */ (function () {
27
51
 
28
52
  var COLUMN_WIDTH_MM = 41;
29
53
  var GUTTER_WIDTH_MM = 3;
30
- var PIXELS_PER_MM = 3.937;
54
+ var PIXELS_PER_MM$1 = 3.937;
31
55
  var Print6ColCanvasDimensions = /** @class */ (function () {
32
56
  function Print6ColCanvasDimensions(width, height) {
33
57
  this.widthUnit = "column(s)";
@@ -37,26 +61,26 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
37
61
  this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
38
62
  this.columnsTotalMm = width * COLUMN_WIDTH_MM;
39
63
  this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
40
- this.widthPx = round(this.widthMm * PIXELS_PER_MM);
64
+ this.widthPx = round(this.widthMm * PIXELS_PER_MM$1);
41
65
  this.height = height;
42
66
  this.heightMm = Math.max(0, height * 10);
43
- this.heightPx = round(this.heightMm * PIXELS_PER_MM);
67
+ this.heightPx = round(this.heightMm * PIXELS_PER_MM$1);
44
68
  }
45
69
  Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
46
70
  return new Print6ColCanvasDimensions(width, height);
47
71
  };
48
72
  Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
49
- return px / PIXELS_PER_MM;
73
+ return px / PIXELS_PER_MM$1;
50
74
  };
51
75
  Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
52
- return px / PIXELS_PER_MM;
76
+ return px / PIXELS_PER_MM$1;
53
77
  };
54
78
  return Print6ColCanvasDimensions;
55
79
  }());
56
80
 
57
81
  var COLUMN_WIDTH_MM$1 = 30.8772;
58
82
  var GUTTER_WIDTH_MM$1 = 2.1053;
59
- var PIXELS_PER_MM$1 = 3.937;
83
+ var PIXELS_PER_MM$2 = 3.937;
60
84
  var Print8ColCanvasDimensions = /** @class */ (function () {
61
85
  function Print8ColCanvasDimensions(width, height) {
62
86
  this.widthUnit = "column(s)";
@@ -66,19 +90,19 @@ var Print8ColCanvasDimensions = /** @class */ (function () {
66
90
  this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
67
91
  this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
68
92
  this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
69
- this.widthPx = round(this.widthMm * PIXELS_PER_MM$1);
93
+ this.widthPx = round(this.widthMm * PIXELS_PER_MM$2);
70
94
  this.height = height;
71
95
  this.heightMm = Math.max(0, height * 10);
72
- this.heightPx = round(this.heightMm * PIXELS_PER_MM$1);
96
+ this.heightPx = round(this.heightMm * PIXELS_PER_MM$2);
73
97
  }
74
98
  Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
75
99
  return new Print8ColCanvasDimensions(width, height);
76
100
  };
77
101
  Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
78
- return px / PIXELS_PER_MM$1;
102
+ return px / PIXELS_PER_MM$2;
79
103
  };
80
104
  Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
81
- return px / PIXELS_PER_MM$1;
105
+ return px / PIXELS_PER_MM$2;
82
106
  };
83
107
  return Print8ColCanvasDimensions;
84
108
  }());
@@ -260,6 +284,63 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
260
284
  return RedrawAllLayoutFunction;
261
285
  }());
262
286
 
287
+ var RepositionCutoffsLayoutFunction = /** @class */ (function () {
288
+ function RepositionCutoffsLayoutFunction() {
289
+ }
290
+ RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
291
+ canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
292
+ .forEach(function (cutoff) { return cutoff.updatePosition(); });
293
+ };
294
+ return RepositionCutoffsLayoutFunction;
295
+ }());
296
+
297
+ var RepositionBordersLayoutFunction = /** @class */ (function () {
298
+ function RepositionBordersLayoutFunction() {
299
+ }
300
+ RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
301
+ canvas.getObjectsByTypeInternal(ObjectType.BORDER)
302
+ .forEach(function (border) { return border.updatePosition(); });
303
+ };
304
+ return RepositionBordersLayoutFunction;
305
+ }());
306
+
307
+ var PinToBottomLayoutFunction = /** @class */ (function () {
308
+ function PinToBottomLayoutFunction() {
309
+ }
310
+ PinToBottomLayoutFunction.prototype.execute = function (canvas) {
311
+ canvas.getObjectsInternal()
312
+ .forEach(function (object) { return object.moveToPinnedPosition(); });
313
+ };
314
+ return PinToBottomLayoutFunction;
315
+ }());
316
+
317
+ var ResizeCanvasLayoutFunction = /** @class */ (function () {
318
+ function ResizeCanvasLayoutFunction() {
319
+ }
320
+ ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
321
+ if (canvas.getLayoutManager().isEnforcedPositioning)
322
+ return;
323
+ if (oc(canvas.getDimensionsRestrictions()).fixed(false))
324
+ return;
325
+ var currentDimensions = canvas.getDimensions();
326
+ var baseDimensions = canvas.getBaseDimensions();
327
+ var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
328
+ .filter(function (text) { return text.isResizeCanvas(); })
329
+ .reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
330
+ var increase = baseDimensions.withSize(currentDimensions.width, 0);
331
+ while (increase.heightPx < textHeightIncreasePx) {
332
+ increase = increase.withSize(increase.width, increase.height + 1);
333
+ }
334
+ var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
335
+ if (currentDimensions.height !== targetHeight.height) {
336
+ canvas.setDimensions(targetHeight);
337
+ }
338
+ canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
339
+ canvas.redraw();
340
+ };
341
+ return ResizeCanvasLayoutFunction;
342
+ }());
343
+
263
344
  var LayoutManager;
264
345
  (function (LayoutManager) {
265
346
  LayoutManager["LEGACY"] = "LEGACY";
@@ -267,6 +348,33 @@ var LayoutManager;
267
348
  LayoutManager["ADVANCED"] = "ADVANCED";
268
349
  })(LayoutManager || (LayoutManager = {}));
269
350
 
351
+ var AdvancedLayoutManager = /** @class */ (function (_super) {
352
+ __extends(AdvancedLayoutManager, _super);
353
+ function AdvancedLayoutManager(canvas) {
354
+ var _this = _super.call(this, canvas) || this;
355
+ _this.key = LayoutManager.ADVANCED;
356
+ _this.pinToBottom = new PinToBottomLayoutFunction();
357
+ _this.redrawAll = new RedrawAllLayoutFunction();
358
+ _this.repositionBorders = new RepositionBordersLayoutFunction();
359
+ _this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
360
+ _this.resizeCanvas = new ResizeCanvasLayoutFunction();
361
+ return _this;
362
+ }
363
+ AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
364
+ this.pinToBottom.execute(this.canvas);
365
+ this.repositionCutoffs.execute(this.canvas);
366
+ this.repositionBorders.execute(this.canvas);
367
+ this.redrawAll.execute(this.canvas);
368
+ };
369
+ AdvancedLayoutManager.prototype.onTextChange = function () {
370
+ this.resizeCanvas.execute(this.canvas);
371
+ };
372
+ AdvancedLayoutManager.prototype.onObjectListChange = function () {
373
+ this.redrawAll.execute(this.canvas);
374
+ };
375
+ return AdvancedLayoutManager;
376
+ }(AbstractLayoutManager));
377
+
270
378
  var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
271
379
  function UpdateObjectDimensionsLayoutFunction() {
272
380
  }
@@ -375,6 +483,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
375
483
  });
376
484
  };
377
485
  StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
486
+ if (oc(canvas.getDimensionsRestrictions()).fixed(false))
487
+ return;
378
488
  var dimensions = canvas.getDimensions();
379
489
  var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
380
490
  while (targetDimensions.heightPx < requiredHeight) {
@@ -428,16 +538,6 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
428
538
  return StackObjectsLayoutFunction;
429
539
  }());
430
540
 
431
- var RepositionBordersLayoutFunction = /** @class */ (function () {
432
- function RepositionBordersLayoutFunction() {
433
- }
434
- RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
435
- canvas.getObjectsByTypeInternal(ObjectType.BORDER)
436
- .forEach(function (border) { return border.updatePosition(); });
437
- };
438
- return RepositionBordersLayoutFunction;
439
- }());
440
-
441
541
  var StandardLayoutManager = /** @class */ (function (_super) {
442
542
  __extends(StandardLayoutManager, _super);
443
543
  function StandardLayoutManager(canvas) {
@@ -3150,76 +3250,4 @@ var InteractiveCanvas = /** @class */ (function (_super) {
3150
3250
  return InteractiveCanvas;
3151
3251
  }(AbstractInteractiveCanvas));
3152
3252
 
3153
- var RepositionCutoffsLayoutFunction = /** @class */ (function () {
3154
- function RepositionCutoffsLayoutFunction() {
3155
- }
3156
- RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
3157
- canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
3158
- .forEach(function (cutoff) { return cutoff.updatePosition(); });
3159
- };
3160
- return RepositionCutoffsLayoutFunction;
3161
- }());
3162
-
3163
- var PinToBottomLayoutFunction = /** @class */ (function () {
3164
- function PinToBottomLayoutFunction() {
3165
- }
3166
- PinToBottomLayoutFunction.prototype.execute = function (canvas) {
3167
- canvas.getObjectsInternal()
3168
- .forEach(function (object) { return object.moveToPinnedPosition(); });
3169
- };
3170
- return PinToBottomLayoutFunction;
3171
- }());
3172
-
3173
- var ResizeCanvasLayoutFunction = /** @class */ (function () {
3174
- function ResizeCanvasLayoutFunction() {
3175
- }
3176
- ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
3177
- if (canvas.getLayoutManager().isEnforcedPositioning)
3178
- return;
3179
- var currentDimensions = canvas.getDimensions();
3180
- var baseDimensions = canvas.getBaseDimensions();
3181
- var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
3182
- .filter(function (text) { return text.isResizeCanvas(); })
3183
- .reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
3184
- var increase = baseDimensions.withSize(currentDimensions.width, 0);
3185
- while (increase.heightPx < textHeightIncreasePx) {
3186
- increase = increase.withSize(increase.width, increase.height + 1);
3187
- }
3188
- var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
3189
- if (currentDimensions.height !== targetHeight.height) {
3190
- canvas.setDimensions(targetHeight);
3191
- }
3192
- canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
3193
- canvas.redraw();
3194
- };
3195
- return ResizeCanvasLayoutFunction;
3196
- }());
3197
-
3198
- var AdvancedLayoutManager = /** @class */ (function (_super) {
3199
- __extends(AdvancedLayoutManager, _super);
3200
- function AdvancedLayoutManager(canvas) {
3201
- var _this = _super.call(this, canvas) || this;
3202
- _this.key = LayoutManager.ADVANCED;
3203
- _this.pinToBottom = new PinToBottomLayoutFunction();
3204
- _this.redrawAll = new RedrawAllLayoutFunction();
3205
- _this.repositionBorders = new RepositionBordersLayoutFunction();
3206
- _this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
3207
- _this.resizeCanvas = new ResizeCanvasLayoutFunction();
3208
- return _this;
3209
- }
3210
- AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
3211
- this.pinToBottom.execute(this.canvas);
3212
- this.repositionCutoffs.execute(this.canvas);
3213
- this.repositionBorders.execute(this.canvas);
3214
- this.redrawAll.execute(this.canvas);
3215
- };
3216
- AdvancedLayoutManager.prototype.onTextChange = function () {
3217
- this.resizeCanvas.execute(this.canvas);
3218
- };
3219
- AdvancedLayoutManager.prototype.onObjectListChange = function () {
3220
- this.redrawAll.execute(this.canvas);
3221
- };
3222
- return AdvancedLayoutManager;
3223
- }(AbstractLayoutManager));
3224
-
3225
- export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
3253
+ export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, MillimeterDimensions, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
@@ -7,6 +7,30 @@ var tsOptchain = require('ts-optchain');
7
7
  var rxjs = require('rxjs');
8
8
  var fabric = require('fabric');
9
9
 
10
+ var PIXELS_PER_MM = 3.937;
11
+ var MillimeterDimensions = /** @class */ (function () {
12
+ function MillimeterDimensions(width, height) {
13
+ this.widthUnit = "mm";
14
+ this.heightUnit = "mm";
15
+ this.width = width;
16
+ this.widthMm = Math.max(0, width);
17
+ this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
18
+ this.height = height;
19
+ this.heightMm = Math.max(0, height);
20
+ this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
21
+ }
22
+ MillimeterDimensions.prototype.withSize = function (width, height) {
23
+ return new MillimeterDimensions(width, height);
24
+ };
25
+ MillimeterDimensions.prototype.widthPxToMm = function (px) {
26
+ return px / PIXELS_PER_MM;
27
+ };
28
+ MillimeterDimensions.prototype.heightPxToMm = function (px) {
29
+ return px / PIXELS_PER_MM;
30
+ };
31
+ return MillimeterDimensions;
32
+ }());
33
+
10
34
  var PixelCanvasDimensions = /** @class */ (function () {
11
35
  function PixelCanvasDimensions(width, height) {
12
36
  this.widthUnit = "px";
@@ -30,7 +54,7 @@ var PixelCanvasDimensions = /** @class */ (function () {
30
54
 
31
55
  var COLUMN_WIDTH_MM = 41;
32
56
  var GUTTER_WIDTH_MM = 3;
33
- var PIXELS_PER_MM = 3.937;
57
+ var PIXELS_PER_MM$1 = 3.937;
34
58
  var Print6ColCanvasDimensions = /** @class */ (function () {
35
59
  function Print6ColCanvasDimensions(width, height) {
36
60
  this.widthUnit = "column(s)";
@@ -40,26 +64,26 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
40
64
  this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
41
65
  this.columnsTotalMm = width * COLUMN_WIDTH_MM;
42
66
  this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
43
- this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
67
+ this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
44
68
  this.height = height;
45
69
  this.heightMm = Math.max(0, height * 10);
46
- this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
70
+ this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$1);
47
71
  }
48
72
  Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
49
73
  return new Print6ColCanvasDimensions(width, height);
50
74
  };
51
75
  Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
52
- return px / PIXELS_PER_MM;
76
+ return px / PIXELS_PER_MM$1;
53
77
  };
54
78
  Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
55
- return px / PIXELS_PER_MM;
79
+ return px / PIXELS_PER_MM$1;
56
80
  };
57
81
  return Print6ColCanvasDimensions;
58
82
  }());
59
83
 
60
84
  var COLUMN_WIDTH_MM$1 = 30.8772;
61
85
  var GUTTER_WIDTH_MM$1 = 2.1053;
62
- var PIXELS_PER_MM$1 = 3.937;
86
+ var PIXELS_PER_MM$2 = 3.937;
63
87
  var Print8ColCanvasDimensions = /** @class */ (function () {
64
88
  function Print8ColCanvasDimensions(width, height) {
65
89
  this.widthUnit = "column(s)";
@@ -69,19 +93,19 @@ var Print8ColCanvasDimensions = /** @class */ (function () {
69
93
  this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
70
94
  this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
71
95
  this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
72
- this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
96
+ this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$2);
73
97
  this.height = height;
74
98
  this.heightMm = Math.max(0, height * 10);
75
- this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$1);
99
+ this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$2);
76
100
  }
77
101
  Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
78
102
  return new Print8ColCanvasDimensions(width, height);
79
103
  };
80
104
  Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
81
- return px / PIXELS_PER_MM$1;
105
+ return px / PIXELS_PER_MM$2;
82
106
  };
83
107
  Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
84
- return px / PIXELS_PER_MM$1;
108
+ return px / PIXELS_PER_MM$2;
85
109
  };
86
110
  return Print8ColCanvasDimensions;
87
111
  }());
@@ -263,12 +287,96 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
263
287
  return RedrawAllLayoutFunction;
264
288
  }());
265
289
 
290
+ var RepositionCutoffsLayoutFunction = /** @class */ (function () {
291
+ function RepositionCutoffsLayoutFunction() {
292
+ }
293
+ RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
294
+ canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
295
+ .forEach(function (cutoff) { return cutoff.updatePosition(); });
296
+ };
297
+ return RepositionCutoffsLayoutFunction;
298
+ }());
299
+
300
+ var RepositionBordersLayoutFunction = /** @class */ (function () {
301
+ function RepositionBordersLayoutFunction() {
302
+ }
303
+ RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
304
+ canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
305
+ .forEach(function (border) { return border.updatePosition(); });
306
+ };
307
+ return RepositionBordersLayoutFunction;
308
+ }());
309
+
310
+ var PinToBottomLayoutFunction = /** @class */ (function () {
311
+ function PinToBottomLayoutFunction() {
312
+ }
313
+ PinToBottomLayoutFunction.prototype.execute = function (canvas) {
314
+ canvas.getObjectsInternal()
315
+ .forEach(function (object) { return object.moveToPinnedPosition(); });
316
+ };
317
+ return PinToBottomLayoutFunction;
318
+ }());
319
+
320
+ var ResizeCanvasLayoutFunction = /** @class */ (function () {
321
+ function ResizeCanvasLayoutFunction() {
322
+ }
323
+ ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
324
+ if (canvas.getLayoutManager().isEnforcedPositioning)
325
+ return;
326
+ if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
327
+ return;
328
+ var currentDimensions = canvas.getDimensions();
329
+ var baseDimensions = canvas.getBaseDimensions();
330
+ var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
331
+ .filter(function (text) { return text.isResizeCanvas(); })
332
+ .reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
333
+ var increase = baseDimensions.withSize(currentDimensions.width, 0);
334
+ while (increase.heightPx < textHeightIncreasePx) {
335
+ increase = increase.withSize(increase.width, increase.height + 1);
336
+ }
337
+ var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
338
+ if (currentDimensions.height !== targetHeight.height) {
339
+ canvas.setDimensions(targetHeight);
340
+ }
341
+ canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
342
+ canvas.redraw();
343
+ };
344
+ return ResizeCanvasLayoutFunction;
345
+ }());
346
+
266
347
  (function (LayoutManager) {
267
348
  LayoutManager["LEGACY"] = "LEGACY";
268
349
  LayoutManager["STANDARD"] = "STANDARD";
269
350
  LayoutManager["ADVANCED"] = "ADVANCED";
270
351
  })(exports.LayoutManager || (exports.LayoutManager = {}));
271
352
 
353
+ var AdvancedLayoutManager = /** @class */ (function (_super) {
354
+ __extends(AdvancedLayoutManager, _super);
355
+ function AdvancedLayoutManager(canvas) {
356
+ var _this = _super.call(this, canvas) || this;
357
+ _this.key = exports.LayoutManager.ADVANCED;
358
+ _this.pinToBottom = new PinToBottomLayoutFunction();
359
+ _this.redrawAll = new RedrawAllLayoutFunction();
360
+ _this.repositionBorders = new RepositionBordersLayoutFunction();
361
+ _this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
362
+ _this.resizeCanvas = new ResizeCanvasLayoutFunction();
363
+ return _this;
364
+ }
365
+ AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
366
+ this.pinToBottom.execute(this.canvas);
367
+ this.repositionCutoffs.execute(this.canvas);
368
+ this.repositionBorders.execute(this.canvas);
369
+ this.redrawAll.execute(this.canvas);
370
+ };
371
+ AdvancedLayoutManager.prototype.onTextChange = function () {
372
+ this.resizeCanvas.execute(this.canvas);
373
+ };
374
+ AdvancedLayoutManager.prototype.onObjectListChange = function () {
375
+ this.redrawAll.execute(this.canvas);
376
+ };
377
+ return AdvancedLayoutManager;
378
+ }(AbstractLayoutManager));
379
+
272
380
  var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
273
381
  function UpdateObjectDimensionsLayoutFunction() {
274
382
  }
@@ -377,6 +485,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
377
485
  });
378
486
  };
379
487
  StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
488
+ if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
489
+ return;
380
490
  var dimensions = canvas.getDimensions();
381
491
  var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
382
492
  while (targetDimensions.heightPx < requiredHeight) {
@@ -430,16 +540,6 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
430
540
  return StackObjectsLayoutFunction;
431
541
  }());
432
542
 
433
- var RepositionBordersLayoutFunction = /** @class */ (function () {
434
- function RepositionBordersLayoutFunction() {
435
- }
436
- RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
437
- canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
438
- .forEach(function (border) { return border.updatePosition(); });
439
- };
440
- return RepositionBordersLayoutFunction;
441
- }());
442
-
443
543
  var StandardLayoutManager = /** @class */ (function (_super) {
444
544
  __extends(StandardLayoutManager, _super);
445
545
  function StandardLayoutManager(canvas) {
@@ -3150,78 +3250,6 @@ var InteractiveCanvas = /** @class */ (function (_super) {
3150
3250
  return InteractiveCanvas;
3151
3251
  }(AbstractInteractiveCanvas));
3152
3252
 
3153
- var RepositionCutoffsLayoutFunction = /** @class */ (function () {
3154
- function RepositionCutoffsLayoutFunction() {
3155
- }
3156
- RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
3157
- canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
3158
- .forEach(function (cutoff) { return cutoff.updatePosition(); });
3159
- };
3160
- return RepositionCutoffsLayoutFunction;
3161
- }());
3162
-
3163
- var PinToBottomLayoutFunction = /** @class */ (function () {
3164
- function PinToBottomLayoutFunction() {
3165
- }
3166
- PinToBottomLayoutFunction.prototype.execute = function (canvas) {
3167
- canvas.getObjectsInternal()
3168
- .forEach(function (object) { return object.moveToPinnedPosition(); });
3169
- };
3170
- return PinToBottomLayoutFunction;
3171
- }());
3172
-
3173
- var ResizeCanvasLayoutFunction = /** @class */ (function () {
3174
- function ResizeCanvasLayoutFunction() {
3175
- }
3176
- ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
3177
- if (canvas.getLayoutManager().isEnforcedPositioning)
3178
- return;
3179
- var currentDimensions = canvas.getDimensions();
3180
- var baseDimensions = canvas.getBaseDimensions();
3181
- var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
3182
- .filter(function (text) { return text.isResizeCanvas(); })
3183
- .reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
3184
- var increase = baseDimensions.withSize(currentDimensions.width, 0);
3185
- while (increase.heightPx < textHeightIncreasePx) {
3186
- increase = increase.withSize(increase.width, increase.height + 1);
3187
- }
3188
- var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
3189
- if (currentDimensions.height !== targetHeight.height) {
3190
- canvas.setDimensions(targetHeight);
3191
- }
3192
- canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
3193
- canvas.redraw();
3194
- };
3195
- return ResizeCanvasLayoutFunction;
3196
- }());
3197
-
3198
- var AdvancedLayoutManager = /** @class */ (function (_super) {
3199
- __extends(AdvancedLayoutManager, _super);
3200
- function AdvancedLayoutManager(canvas) {
3201
- var _this = _super.call(this, canvas) || this;
3202
- _this.key = exports.LayoutManager.ADVANCED;
3203
- _this.pinToBottom = new PinToBottomLayoutFunction();
3204
- _this.redrawAll = new RedrawAllLayoutFunction();
3205
- _this.repositionBorders = new RepositionBordersLayoutFunction();
3206
- _this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
3207
- _this.resizeCanvas = new ResizeCanvasLayoutFunction();
3208
- return _this;
3209
- }
3210
- AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
3211
- this.pinToBottom.execute(this.canvas);
3212
- this.repositionCutoffs.execute(this.canvas);
3213
- this.repositionBorders.execute(this.canvas);
3214
- this.redrawAll.execute(this.canvas);
3215
- };
3216
- AdvancedLayoutManager.prototype.onTextChange = function () {
3217
- this.resizeCanvas.execute(this.canvas);
3218
- };
3219
- AdvancedLayoutManager.prototype.onObjectListChange = function () {
3220
- this.redrawAll.execute(this.canvas);
3221
- };
3222
- return AdvancedLayoutManager;
3223
- }(AbstractLayoutManager));
3224
-
3225
3253
  exports.AbstractCanvasObject = AbstractCanvasObject;
3226
3254
  exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
3227
3255
  exports.AbstractLayoutManager = AbstractLayoutManager;
@@ -3236,6 +3264,7 @@ exports.HeadlessInteractiveCanvas = HeadlessInteractiveCanvas;
3236
3264
  exports.HorizontalRule = HorizontalRule;
3237
3265
  exports.Image = Image;
3238
3266
  exports.InteractiveCanvas = InteractiveCanvas;
3267
+ exports.MillimeterDimensions = MillimeterDimensions;
3239
3268
  exports.PixelCanvasDimensions = PixelCanvasDimensions;
3240
3269
  exports.Print6ColCanvasDimensions = Print6ColCanvasDimensions;
3241
3270
  exports.Print8ColCanvasDimensions = Print8ColCanvasDimensions;
@@ -11,4 +11,5 @@ export interface ICanvasDimensionRestrictions {
11
11
  min?: number;
12
12
  max?: number;
13
13
  };
14
+ readonly fixed?: boolean;
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"