@leapfrog/interactive-canvas 1.4.3 → 1.5.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.
|
@@ -485,7 +485,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
485
485
|
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
486
486
|
return;
|
|
487
487
|
var dimensions = canvas.getDimensions();
|
|
488
|
-
var
|
|
488
|
+
var minHeight = oc(canvas.getDimensionsRestrictions()).height.min(MIN_MAGNITUDE);
|
|
489
|
+
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, minHeight);
|
|
489
490
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
490
491
|
targetDimensions = targetDimensions.withSize(dimensions.width, targetDimensions.height + 1);
|
|
491
492
|
}
|
|
@@ -1433,10 +1434,19 @@ var Image = /** @class */ (function (_super) {
|
|
|
1433
1434
|
* @inheritDoc
|
|
1434
1435
|
*/
|
|
1435
1436
|
Image.prototype.setImageUrl = function (url) {
|
|
1436
|
-
this
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1437
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1438
|
+
return __generator(this, function (_a) {
|
|
1439
|
+
switch (_a.label) {
|
|
1440
|
+
case 0: return [4 /*yield*/, this.setCanvasImage(url)];
|
|
1441
|
+
case 1:
|
|
1442
|
+
_a.sent();
|
|
1443
|
+
this.data.imagePath = url;
|
|
1444
|
+
this.imageUrl$.next(url);
|
|
1445
|
+
this.canvas.notifyObjectListChanged();
|
|
1446
|
+
return [2 /*return*/];
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
});
|
|
1440
1450
|
};
|
|
1441
1451
|
/**
|
|
1442
1452
|
* @override
|
|
@@ -1531,24 +1541,35 @@ var Image = /** @class */ (function (_super) {
|
|
|
1531
1541
|
this.fabricObject.set({ left: left + (this.layoutWidth / 2) - (imageWidth / 2) });
|
|
1532
1542
|
};
|
|
1533
1543
|
Image.prototype.setCanvasImage = function (url) {
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1544
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1545
|
+
var imageOptions, maxSizeScale, maxWidth;
|
|
1546
|
+
var _this = this;
|
|
1547
|
+
return __generator(this, function (_a) {
|
|
1548
|
+
switch (_a.label) {
|
|
1549
|
+
case 0:
|
|
1550
|
+
imageOptions = { crossOrigin: "anonymous" };
|
|
1551
|
+
maxSizeScale = 2;
|
|
1552
|
+
maxWidth = this.canvas.getDimensions().widthPx / maxSizeScale;
|
|
1553
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
1554
|
+
_this.fabricObject.setSrc(url, function (img) {
|
|
1555
|
+
var newScale = 1;
|
|
1556
|
+
var curWidth = newScale * img.width;
|
|
1557
|
+
if (curWidth > maxWidth) {
|
|
1558
|
+
newScale = maxWidth / curWidth;
|
|
1559
|
+
}
|
|
1560
|
+
img.set({
|
|
1561
|
+
scaleX: newScale,
|
|
1562
|
+
scaleY: newScale
|
|
1563
|
+
});
|
|
1564
|
+
img.setCoords();
|
|
1565
|
+
_this.redraw();
|
|
1566
|
+
resolve();
|
|
1567
|
+
}, imageOptions);
|
|
1568
|
+
})];
|
|
1569
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1570
|
+
}
|
|
1548
1571
|
});
|
|
1549
|
-
|
|
1550
|
-
_this.redraw();
|
|
1551
|
-
}, imageOptions);
|
|
1572
|
+
});
|
|
1552
1573
|
};
|
|
1553
1574
|
Image.prototype.getMinWidthBasedOnMinHeight = function (minHeight) {
|
|
1554
1575
|
if (!minHeight) {
|
|
@@ -487,7 +487,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
487
487
|
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
488
488
|
return;
|
|
489
489
|
var dimensions = canvas.getDimensions();
|
|
490
|
-
var
|
|
490
|
+
var minHeight = tsOptchain.oc(canvas.getDimensionsRestrictions()).height.min(MIN_MAGNITUDE);
|
|
491
|
+
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, minHeight);
|
|
491
492
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
492
493
|
targetDimensions = targetDimensions.withSize(dimensions.width, targetDimensions.height + 1);
|
|
493
494
|
}
|
|
@@ -1435,10 +1436,19 @@ var Image = /** @class */ (function (_super) {
|
|
|
1435
1436
|
* @inheritDoc
|
|
1436
1437
|
*/
|
|
1437
1438
|
Image.prototype.setImageUrl = function (url) {
|
|
1438
|
-
this
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1439
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1440
|
+
return __generator(this, function (_a) {
|
|
1441
|
+
switch (_a.label) {
|
|
1442
|
+
case 0: return [4 /*yield*/, this.setCanvasImage(url)];
|
|
1443
|
+
case 1:
|
|
1444
|
+
_a.sent();
|
|
1445
|
+
this.data.imagePath = url;
|
|
1446
|
+
this.imageUrl$.next(url);
|
|
1447
|
+
this.canvas.notifyObjectListChanged();
|
|
1448
|
+
return [2 /*return*/];
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
});
|
|
1442
1452
|
};
|
|
1443
1453
|
/**
|
|
1444
1454
|
* @override
|
|
@@ -1533,24 +1543,35 @@ var Image = /** @class */ (function (_super) {
|
|
|
1533
1543
|
this.fabricObject.set({ left: left + (this.layoutWidth / 2) - (imageWidth / 2) });
|
|
1534
1544
|
};
|
|
1535
1545
|
Image.prototype.setCanvasImage = function (url) {
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1546
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1547
|
+
var imageOptions, maxSizeScale, maxWidth;
|
|
1548
|
+
var _this = this;
|
|
1549
|
+
return __generator(this, function (_a) {
|
|
1550
|
+
switch (_a.label) {
|
|
1551
|
+
case 0:
|
|
1552
|
+
imageOptions = { crossOrigin: "anonymous" };
|
|
1553
|
+
maxSizeScale = 2;
|
|
1554
|
+
maxWidth = this.canvas.getDimensions().widthPx / maxSizeScale;
|
|
1555
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
1556
|
+
_this.fabricObject.setSrc(url, function (img) {
|
|
1557
|
+
var newScale = 1;
|
|
1558
|
+
var curWidth = newScale * img.width;
|
|
1559
|
+
if (curWidth > maxWidth) {
|
|
1560
|
+
newScale = maxWidth / curWidth;
|
|
1561
|
+
}
|
|
1562
|
+
img.set({
|
|
1563
|
+
scaleX: newScale,
|
|
1564
|
+
scaleY: newScale
|
|
1565
|
+
});
|
|
1566
|
+
img.setCoords();
|
|
1567
|
+
_this.redraw();
|
|
1568
|
+
resolve();
|
|
1569
|
+
}, imageOptions);
|
|
1570
|
+
})];
|
|
1571
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1572
|
+
}
|
|
1550
1573
|
});
|
|
1551
|
-
|
|
1552
|
-
_this.redraw();
|
|
1553
|
-
}, imageOptions);
|
|
1574
|
+
});
|
|
1554
1575
|
};
|
|
1555
1576
|
Image.prototype.getMinWidthBasedOnMinHeight = function (minHeight) {
|
|
1556
1577
|
if (!minHeight) {
|