@leapfrog/interactive-canvas 1.4.2 → 1.5.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.
|
@@ -564,6 +564,13 @@ var StandardLayoutManager = /** @class */ (function (_super) {
|
|
|
564
564
|
this.canvas.setMultiSelect(false);
|
|
565
565
|
this.redrawAll.execute(this.canvas);
|
|
566
566
|
};
|
|
567
|
+
/**
|
|
568
|
+
* @override
|
|
569
|
+
*/
|
|
570
|
+
StandardLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
571
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
572
|
+
this.repositionBorders.execute(this.canvas);
|
|
573
|
+
};
|
|
567
574
|
/**
|
|
568
575
|
* @override
|
|
569
576
|
*/
|
|
@@ -1426,10 +1433,19 @@ var Image = /** @class */ (function (_super) {
|
|
|
1426
1433
|
* @inheritDoc
|
|
1427
1434
|
*/
|
|
1428
1435
|
Image.prototype.setImageUrl = function (url) {
|
|
1429
|
-
this
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1436
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1437
|
+
return __generator(this, function (_a) {
|
|
1438
|
+
switch (_a.label) {
|
|
1439
|
+
case 0: return [4 /*yield*/, this.setCanvasImage(url)];
|
|
1440
|
+
case 1:
|
|
1441
|
+
_a.sent();
|
|
1442
|
+
this.data.imagePath = url;
|
|
1443
|
+
this.imageUrl$.next(url);
|
|
1444
|
+
this.canvas.notifyObjectListChanged();
|
|
1445
|
+
return [2 /*return*/];
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
});
|
|
1433
1449
|
};
|
|
1434
1450
|
/**
|
|
1435
1451
|
* @override
|
|
@@ -1524,24 +1540,35 @@ var Image = /** @class */ (function (_super) {
|
|
|
1524
1540
|
this.fabricObject.set({ left: left + (this.layoutWidth / 2) - (imageWidth / 2) });
|
|
1525
1541
|
};
|
|
1526
1542
|
Image.prototype.setCanvasImage = function (url) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1543
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1544
|
+
var imageOptions, maxSizeScale, maxWidth;
|
|
1545
|
+
var _this = this;
|
|
1546
|
+
return __generator(this, function (_a) {
|
|
1547
|
+
switch (_a.label) {
|
|
1548
|
+
case 0:
|
|
1549
|
+
imageOptions = { crossOrigin: "anonymous" };
|
|
1550
|
+
maxSizeScale = 2;
|
|
1551
|
+
maxWidth = this.canvas.getDimensions().widthPx / maxSizeScale;
|
|
1552
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
1553
|
+
_this.fabricObject.setSrc(url, function (img) {
|
|
1554
|
+
var newScale = 1;
|
|
1555
|
+
var curWidth = newScale * img.width;
|
|
1556
|
+
if (curWidth > maxWidth) {
|
|
1557
|
+
newScale = maxWidth / curWidth;
|
|
1558
|
+
}
|
|
1559
|
+
img.set({
|
|
1560
|
+
scaleX: newScale,
|
|
1561
|
+
scaleY: newScale
|
|
1562
|
+
});
|
|
1563
|
+
img.setCoords();
|
|
1564
|
+
_this.redraw();
|
|
1565
|
+
resolve();
|
|
1566
|
+
}, imageOptions);
|
|
1567
|
+
})];
|
|
1568
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1569
|
+
}
|
|
1541
1570
|
});
|
|
1542
|
-
|
|
1543
|
-
_this.redraw();
|
|
1544
|
-
}, imageOptions);
|
|
1571
|
+
});
|
|
1545
1572
|
};
|
|
1546
1573
|
Image.prototype.getMinWidthBasedOnMinHeight = function (minHeight) {
|
|
1547
1574
|
if (!minHeight) {
|
|
@@ -566,6 +566,13 @@ var StandardLayoutManager = /** @class */ (function (_super) {
|
|
|
566
566
|
this.canvas.setMultiSelect(false);
|
|
567
567
|
this.redrawAll.execute(this.canvas);
|
|
568
568
|
};
|
|
569
|
+
/**
|
|
570
|
+
* @override
|
|
571
|
+
*/
|
|
572
|
+
StandardLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
573
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
574
|
+
this.repositionBorders.execute(this.canvas);
|
|
575
|
+
};
|
|
569
576
|
/**
|
|
570
577
|
* @override
|
|
571
578
|
*/
|
|
@@ -1428,10 +1435,19 @@ var Image = /** @class */ (function (_super) {
|
|
|
1428
1435
|
* @inheritDoc
|
|
1429
1436
|
*/
|
|
1430
1437
|
Image.prototype.setImageUrl = function (url) {
|
|
1431
|
-
this
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1438
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1439
|
+
return __generator(this, function (_a) {
|
|
1440
|
+
switch (_a.label) {
|
|
1441
|
+
case 0: return [4 /*yield*/, this.setCanvasImage(url)];
|
|
1442
|
+
case 1:
|
|
1443
|
+
_a.sent();
|
|
1444
|
+
this.data.imagePath = url;
|
|
1445
|
+
this.imageUrl$.next(url);
|
|
1446
|
+
this.canvas.notifyObjectListChanged();
|
|
1447
|
+
return [2 /*return*/];
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
});
|
|
1435
1451
|
};
|
|
1436
1452
|
/**
|
|
1437
1453
|
* @override
|
|
@@ -1526,24 +1542,35 @@ var Image = /** @class */ (function (_super) {
|
|
|
1526
1542
|
this.fabricObject.set({ left: left + (this.layoutWidth / 2) - (imageWidth / 2) });
|
|
1527
1543
|
};
|
|
1528
1544
|
Image.prototype.setCanvasImage = function (url) {
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1545
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1546
|
+
var imageOptions, maxSizeScale, maxWidth;
|
|
1547
|
+
var _this = this;
|
|
1548
|
+
return __generator(this, function (_a) {
|
|
1549
|
+
switch (_a.label) {
|
|
1550
|
+
case 0:
|
|
1551
|
+
imageOptions = { crossOrigin: "anonymous" };
|
|
1552
|
+
maxSizeScale = 2;
|
|
1553
|
+
maxWidth = this.canvas.getDimensions().widthPx / maxSizeScale;
|
|
1554
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
1555
|
+
_this.fabricObject.setSrc(url, function (img) {
|
|
1556
|
+
var newScale = 1;
|
|
1557
|
+
var curWidth = newScale * img.width;
|
|
1558
|
+
if (curWidth > maxWidth) {
|
|
1559
|
+
newScale = maxWidth / curWidth;
|
|
1560
|
+
}
|
|
1561
|
+
img.set({
|
|
1562
|
+
scaleX: newScale,
|
|
1563
|
+
scaleY: newScale
|
|
1564
|
+
});
|
|
1565
|
+
img.setCoords();
|
|
1566
|
+
_this.redraw();
|
|
1567
|
+
resolve();
|
|
1568
|
+
}, imageOptions);
|
|
1569
|
+
})];
|
|
1570
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1571
|
+
}
|
|
1543
1572
|
});
|
|
1544
|
-
|
|
1545
|
-
_this.redraw();
|
|
1546
|
-
}, imageOptions);
|
|
1573
|
+
});
|
|
1547
1574
|
};
|
|
1548
1575
|
Image.prototype.getMinWidthBasedOnMinHeight = function (minHeight) {
|
|
1549
1576
|
if (!minHeight) {
|