@leapfrog/interactive-canvas 1.0.5 → 1.0.7

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.
@@ -260,61 +260,6 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
260
260
  return RedrawAllLayoutFunction;
261
261
  }());
262
262
 
263
- var RepositionCutoffsLayoutFunction = /** @class */ (function () {
264
- function RepositionCutoffsLayoutFunction() {
265
- }
266
- RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
267
- canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
268
- .forEach(function (cutoff) { return cutoff.updatePosition(); });
269
- };
270
- return RepositionCutoffsLayoutFunction;
271
- }());
272
-
273
- var RepositionBordersLayoutFunction = /** @class */ (function () {
274
- function RepositionBordersLayoutFunction() {
275
- }
276
- RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
277
- canvas.getObjectsByTypeInternal(ObjectType.BORDER)
278
- .forEach(function (border) { return border.updatePosition(); });
279
- };
280
- return RepositionBordersLayoutFunction;
281
- }());
282
-
283
- var PinToBottomLayoutFunction = /** @class */ (function () {
284
- function PinToBottomLayoutFunction() {
285
- }
286
- PinToBottomLayoutFunction.prototype.execute = function (canvas) {
287
- canvas.getObjectsInternal()
288
- .forEach(function (object) { return object.moveToPinnedPosition(); });
289
- };
290
- return PinToBottomLayoutFunction;
291
- }());
292
-
293
- var ResizeCanvasLayoutFunction = /** @class */ (function () {
294
- function ResizeCanvasLayoutFunction() {
295
- }
296
- ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
297
- if (canvas.getLayoutManager().isEnforcedPositioning)
298
- return;
299
- var currentDimensions = canvas.getDimensions();
300
- var baseDimensions = canvas.getBaseDimensions();
301
- var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
302
- .filter(function (text) { return text.isResizeCanvas(); })
303
- .reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
304
- var increase = baseDimensions.withSize(currentDimensions.width, 0);
305
- while (increase.heightPx < textHeightIncreasePx) {
306
- increase = increase.withSize(increase.width, increase.height + 1);
307
- }
308
- var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
309
- if (currentDimensions.height !== targetHeight.height) {
310
- canvas.setDimensions(targetHeight);
311
- }
312
- canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
313
- canvas.redraw();
314
- };
315
- return ResizeCanvasLayoutFunction;
316
- }());
317
-
318
263
  var LayoutManager;
319
264
  (function (LayoutManager) {
320
265
  LayoutManager["LEGACY"] = "LEGACY";
@@ -322,33 +267,6 @@ var LayoutManager;
322
267
  LayoutManager["ADVANCED"] = "ADVANCED";
323
268
  })(LayoutManager || (LayoutManager = {}));
324
269
 
325
- var AdvancedLayoutManager = /** @class */ (function (_super) {
326
- __extends(AdvancedLayoutManager, _super);
327
- function AdvancedLayoutManager(canvas) {
328
- var _this = _super.call(this, canvas) || this;
329
- _this.key = LayoutManager.ADVANCED;
330
- _this.pinToBottom = new PinToBottomLayoutFunction();
331
- _this.redrawAll = new RedrawAllLayoutFunction();
332
- _this.repositionBorders = new RepositionBordersLayoutFunction();
333
- _this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
334
- _this.resizeCanvas = new ResizeCanvasLayoutFunction();
335
- return _this;
336
- }
337
- AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
338
- this.pinToBottom.execute(this.canvas);
339
- this.repositionCutoffs.execute(this.canvas);
340
- this.repositionBorders.execute(this.canvas);
341
- this.redrawAll.execute(this.canvas);
342
- };
343
- AdvancedLayoutManager.prototype.onTextChange = function () {
344
- this.resizeCanvas.execute(this.canvas);
345
- };
346
- AdvancedLayoutManager.prototype.onObjectListChange = function () {
347
- this.redrawAll.execute(this.canvas);
348
- };
349
- return AdvancedLayoutManager;
350
- }(AbstractLayoutManager));
351
-
352
270
  var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
353
271
  function UpdateObjectDimensionsLayoutFunction() {
354
272
  }
@@ -510,6 +428,16 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
510
428
  return StackObjectsLayoutFunction;
511
429
  }());
512
430
 
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
+
513
441
  var StandardLayoutManager = /** @class */ (function (_super) {
514
442
  __extends(StandardLayoutManager, _super);
515
443
  function StandardLayoutManager(canvas) {
@@ -1043,20 +971,20 @@ var Border = /** @class */ (function (_super) {
1043
971
  };
1044
972
  Border.prototype.getPadding = function () {
1045
973
  return this.data.padding || {
1046
- top: 2,
1047
- right: 2,
1048
- bottom: 2,
1049
- left: 2
974
+ top: 0,
975
+ right: 0,
976
+ bottom: 0,
977
+ left: 0
1050
978
  };
1051
979
  };
1052
980
  Border.prototype.setPadding = function (padding) {
1053
981
  if (!padding)
1054
982
  return;
1055
983
  this.data.padding = {
1056
- top: padding.top || 2,
1057
- right: padding.right || 2,
1058
- bottom: padding.bottom || 2,
1059
- left: padding.left || 2
984
+ top: padding.top || 0,
985
+ right: padding.right || 0,
986
+ bottom: padding.bottom || 0,
987
+ left: padding.left || 0
1060
988
  };
1061
989
  this.canvas.notifyMarginChanged();
1062
990
  this.redraw();
@@ -2483,7 +2411,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
2483
2411
  top: Math.max(current.top, next.top),
2484
2412
  right: Math.max(current.right, next.right),
2485
2413
  bottom: Math.max(current.bottom, next.bottom),
2486
- left: Math.max(current.bottom, next.bottom)
2414
+ left: Math.max(current.left, next.left)
2487
2415
  };
2488
2416
  }, { top: 0, right: 0, bottom: 0, left: 0 });
2489
2417
  var cutoffWidth = this.getObjectsByTypeInternal(ObjectType.CUTOFF)
@@ -3222,4 +3150,76 @@ var InteractiveCanvas = /** @class */ (function (_super) {
3222
3150
  return InteractiveCanvas;
3223
3151
  }(AbstractInteractiveCanvas));
3224
3152
 
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
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 };
@@ -263,94 +263,12 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
263
263
  return RedrawAllLayoutFunction;
264
264
  }());
265
265
 
266
- var RepositionCutoffsLayoutFunction = /** @class */ (function () {
267
- function RepositionCutoffsLayoutFunction() {
268
- }
269
- RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
270
- canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
271
- .forEach(function (cutoff) { return cutoff.updatePosition(); });
272
- };
273
- return RepositionCutoffsLayoutFunction;
274
- }());
275
-
276
- var RepositionBordersLayoutFunction = /** @class */ (function () {
277
- function RepositionBordersLayoutFunction() {
278
- }
279
- RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
280
- canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
281
- .forEach(function (border) { return border.updatePosition(); });
282
- };
283
- return RepositionBordersLayoutFunction;
284
- }());
285
-
286
- var PinToBottomLayoutFunction = /** @class */ (function () {
287
- function PinToBottomLayoutFunction() {
288
- }
289
- PinToBottomLayoutFunction.prototype.execute = function (canvas) {
290
- canvas.getObjectsInternal()
291
- .forEach(function (object) { return object.moveToPinnedPosition(); });
292
- };
293
- return PinToBottomLayoutFunction;
294
- }());
295
-
296
- var ResizeCanvasLayoutFunction = /** @class */ (function () {
297
- function ResizeCanvasLayoutFunction() {
298
- }
299
- ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
300
- if (canvas.getLayoutManager().isEnforcedPositioning)
301
- return;
302
- var currentDimensions = canvas.getDimensions();
303
- var baseDimensions = canvas.getBaseDimensions();
304
- var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
305
- .filter(function (text) { return text.isResizeCanvas(); })
306
- .reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
307
- var increase = baseDimensions.withSize(currentDimensions.width, 0);
308
- while (increase.heightPx < textHeightIncreasePx) {
309
- increase = increase.withSize(increase.width, increase.height + 1);
310
- }
311
- var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
312
- if (currentDimensions.height !== targetHeight.height) {
313
- canvas.setDimensions(targetHeight);
314
- }
315
- canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
316
- canvas.redraw();
317
- };
318
- return ResizeCanvasLayoutFunction;
319
- }());
320
-
321
266
  (function (LayoutManager) {
322
267
  LayoutManager["LEGACY"] = "LEGACY";
323
268
  LayoutManager["STANDARD"] = "STANDARD";
324
269
  LayoutManager["ADVANCED"] = "ADVANCED";
325
270
  })(exports.LayoutManager || (exports.LayoutManager = {}));
326
271
 
327
- var AdvancedLayoutManager = /** @class */ (function (_super) {
328
- __extends(AdvancedLayoutManager, _super);
329
- function AdvancedLayoutManager(canvas) {
330
- var _this = _super.call(this, canvas) || this;
331
- _this.key = exports.LayoutManager.ADVANCED;
332
- _this.pinToBottom = new PinToBottomLayoutFunction();
333
- _this.redrawAll = new RedrawAllLayoutFunction();
334
- _this.repositionBorders = new RepositionBordersLayoutFunction();
335
- _this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
336
- _this.resizeCanvas = new ResizeCanvasLayoutFunction();
337
- return _this;
338
- }
339
- AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
340
- this.pinToBottom.execute(this.canvas);
341
- this.repositionCutoffs.execute(this.canvas);
342
- this.repositionBorders.execute(this.canvas);
343
- this.redrawAll.execute(this.canvas);
344
- };
345
- AdvancedLayoutManager.prototype.onTextChange = function () {
346
- this.resizeCanvas.execute(this.canvas);
347
- };
348
- AdvancedLayoutManager.prototype.onObjectListChange = function () {
349
- this.redrawAll.execute(this.canvas);
350
- };
351
- return AdvancedLayoutManager;
352
- }(AbstractLayoutManager));
353
-
354
272
  var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
355
273
  function UpdateObjectDimensionsLayoutFunction() {
356
274
  }
@@ -512,6 +430,16 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
512
430
  return StackObjectsLayoutFunction;
513
431
  }());
514
432
 
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
+
515
443
  var StandardLayoutManager = /** @class */ (function (_super) {
516
444
  __extends(StandardLayoutManager, _super);
517
445
  function StandardLayoutManager(canvas) {
@@ -1045,20 +973,20 @@ var Border = /** @class */ (function (_super) {
1045
973
  };
1046
974
  Border.prototype.getPadding = function () {
1047
975
  return this.data.padding || {
1048
- top: 2,
1049
- right: 2,
1050
- bottom: 2,
1051
- left: 2
976
+ top: 0,
977
+ right: 0,
978
+ bottom: 0,
979
+ left: 0
1052
980
  };
1053
981
  };
1054
982
  Border.prototype.setPadding = function (padding) {
1055
983
  if (!padding)
1056
984
  return;
1057
985
  this.data.padding = {
1058
- top: padding.top || 2,
1059
- right: padding.right || 2,
1060
- bottom: padding.bottom || 2,
1061
- left: padding.left || 2
986
+ top: padding.top || 0,
987
+ right: padding.right || 0,
988
+ bottom: padding.bottom || 0,
989
+ left: padding.left || 0
1062
990
  };
1063
991
  this.canvas.notifyMarginChanged();
1064
992
  this.redraw();
@@ -2483,7 +2411,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
2483
2411
  top: Math.max(current.top, next.top),
2484
2412
  right: Math.max(current.right, next.right),
2485
2413
  bottom: Math.max(current.bottom, next.bottom),
2486
- left: Math.max(current.bottom, next.bottom)
2414
+ left: Math.max(current.left, next.left)
2487
2415
  };
2488
2416
  }, { top: 0, right: 0, bottom: 0, left: 0 });
2489
2417
  var cutoffWidth = this.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
@@ -3222,6 +3150,78 @@ var InteractiveCanvas = /** @class */ (function (_super) {
3222
3150
  return InteractiveCanvas;
3223
3151
  }(AbstractInteractiveCanvas));
3224
3152
 
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
3225
  exports.AbstractCanvasObject = AbstractCanvasObject;
3226
3226
  exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
3227
3227
  exports.AbstractLayoutManager = AbstractLayoutManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"