@leapfrog/interactive-canvas 1.2.0 → 1.3.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.
- package/dist/interactive-canvas.es.js +17 -25
- package/dist/interactive-canvas.js +17 -25
- package/package.json +1 -1
|
@@ -916,7 +916,8 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
916
916
|
this.fabricObject.set({ scaleX: position.scaleX });
|
|
917
917
|
if (position.scaleY != undefined)
|
|
918
918
|
this.fabricObject.set({ scaleY: position.scaleY });
|
|
919
|
-
this.
|
|
919
|
+
this.setCoords();
|
|
920
|
+
this.redraw();
|
|
920
921
|
};
|
|
921
922
|
AbstractCanvasObject.prototype.setCoords = function () {
|
|
922
923
|
this.fabricObject.setCoords();
|
|
@@ -2086,29 +2087,22 @@ var Text = /** @class */ (function (_super) {
|
|
|
2086
2087
|
var bullets = fabricText._bullets;
|
|
2087
2088
|
if (bullets && bullets[lineIndex]) {
|
|
2088
2089
|
var bullet = bullets[lineIndex];
|
|
2089
|
-
var bulletIndent = 10;
|
|
2090
|
-
var bulletLeft = fabricText.left + (left - fabricText._getLeftOffset() - bulletIndent) * fabricText.scaleX;
|
|
2091
|
-
if (bullet.left !== bulletLeft) {
|
|
2092
|
-
bullet.set({ left: bulletLeft });
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
* What an out-and-out mess... this calculation is a joke, and the bulletOffset is just an approximation of values that look ok for
|
|
2096
|
-
* the font sizes we use. The 'top' value provided is actutally the... bottom? of the line... and not the line... the bottom of where
|
|
2097
|
-
* the font is rendered... subtracting the `fabricText.getHeightOfLine(lineIndex)` line hieght doesn't give you the top, because the
|
|
2098
|
-
* line height is actually the height of the font plus the excess line height added via the text line-height property.
|
|
2099
|
-
* I couldn't figure out how to get the actual top of the line in two days of trying to understand this ridiculous library.
|
|
2100
|
-
* So, here... bullets. That sort of work... sometimes.
|
|
2101
|
-
*/
|
|
2102
|
-
var textOriginTop = fabricText.top + (fabricText.height / 2);
|
|
2103
2090
|
var fontSize = this.getValueOfPropertyAt(lineIndex, 0, "fontSize");
|
|
2104
|
-
var
|
|
2105
|
-
var
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2091
|
+
var color = this.getValueOfPropertyAt(lineIndex, 0, "fill");
|
|
2092
|
+
var radius = fontSize / 5;
|
|
2093
|
+
var angle = fabricText.angle;
|
|
2094
|
+
var theta = angle * Math.PI / 180;
|
|
2095
|
+
var x = -radius * 2;
|
|
2096
|
+
var y = (fabricText.height / 2) + top - (fontSize / 1.5);
|
|
2097
|
+
var xOffset = (x * Math.cos(theta)) - (y * Math.sin(theta));
|
|
2098
|
+
var yOffset = (x * Math.sin(theta)) + (y * Math.cos(theta));
|
|
2099
|
+
var bulletCenterOffset = [-radius * Math.sqrt(2) / 2, -radius * Math.sqrt(2) / 2];
|
|
2100
|
+
bullet.set({
|
|
2101
|
+
radius: radius,
|
|
2102
|
+
fill: color,
|
|
2103
|
+
left: fabricText.left + xOffset + bulletCenterOffset[0],
|
|
2104
|
+
top: fabricText.top + yOffset + bulletCenterOffset[1]
|
|
2105
|
+
});
|
|
2112
2106
|
}
|
|
2113
2107
|
originalRenderTextLine.apply(fabricText, [method, ctx, line, left, top, lineIndex]);
|
|
2114
2108
|
};
|
|
@@ -2478,7 +2472,6 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2478
2472
|
this.updateCanvasDimensions(dimensions, this.zoom$.value);
|
|
2479
2473
|
this.dimensions$.next(dimensions);
|
|
2480
2474
|
this.onDimensionsChange();
|
|
2481
|
-
this.notifyObjectListChanged();
|
|
2482
2475
|
};
|
|
2483
2476
|
/**
|
|
2484
2477
|
* @override
|
|
@@ -2487,7 +2480,6 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2487
2480
|
AbstractInteractiveCanvas.prototype.setBaseDimensions = function (dimensions) {
|
|
2488
2481
|
this.baseDimensions = dimensions;
|
|
2489
2482
|
this.setDimensions(dimensions);
|
|
2490
|
-
this.notifyObjectListChanged();
|
|
2491
2483
|
};
|
|
2492
2484
|
/**
|
|
2493
2485
|
* @override
|
|
@@ -918,7 +918,8 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
918
918
|
this.fabricObject.set({ scaleX: position.scaleX });
|
|
919
919
|
if (position.scaleY != undefined)
|
|
920
920
|
this.fabricObject.set({ scaleY: position.scaleY });
|
|
921
|
-
this.
|
|
921
|
+
this.setCoords();
|
|
922
|
+
this.redraw();
|
|
922
923
|
};
|
|
923
924
|
AbstractCanvasObject.prototype.setCoords = function () {
|
|
924
925
|
this.fabricObject.setCoords();
|
|
@@ -2088,29 +2089,22 @@ var Text = /** @class */ (function (_super) {
|
|
|
2088
2089
|
var bullets = fabricText._bullets;
|
|
2089
2090
|
if (bullets && bullets[lineIndex]) {
|
|
2090
2091
|
var bullet = bullets[lineIndex];
|
|
2091
|
-
var bulletIndent = 10;
|
|
2092
|
-
var bulletLeft = fabricText.left + (left - fabricText._getLeftOffset() - bulletIndent) * fabricText.scaleX;
|
|
2093
|
-
if (bullet.left !== bulletLeft) {
|
|
2094
|
-
bullet.set({ left: bulletLeft });
|
|
2095
|
-
}
|
|
2096
|
-
/**
|
|
2097
|
-
* What an out-and-out mess... this calculation is a joke, and the bulletOffset is just an approximation of values that look ok for
|
|
2098
|
-
* the font sizes we use. The 'top' value provided is actutally the... bottom? of the line... and not the line... the bottom of where
|
|
2099
|
-
* the font is rendered... subtracting the `fabricText.getHeightOfLine(lineIndex)` line hieght doesn't give you the top, because the
|
|
2100
|
-
* line height is actually the height of the font plus the excess line height added via the text line-height property.
|
|
2101
|
-
* I couldn't figure out how to get the actual top of the line in two days of trying to understand this ridiculous library.
|
|
2102
|
-
* So, here... bullets. That sort of work... sometimes.
|
|
2103
|
-
*/
|
|
2104
|
-
var textOriginTop = fabricText.top + (fabricText.height / 2);
|
|
2105
2092
|
var fontSize = this.getValueOfPropertyAt(lineIndex, 0, "fontSize");
|
|
2106
|
-
var
|
|
2107
|
-
var
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2093
|
+
var color = this.getValueOfPropertyAt(lineIndex, 0, "fill");
|
|
2094
|
+
var radius = fontSize / 5;
|
|
2095
|
+
var angle = fabricText.angle;
|
|
2096
|
+
var theta = angle * Math.PI / 180;
|
|
2097
|
+
var x = -radius * 2;
|
|
2098
|
+
var y = (fabricText.height / 2) + top - (fontSize / 1.5);
|
|
2099
|
+
var xOffset = (x * Math.cos(theta)) - (y * Math.sin(theta));
|
|
2100
|
+
var yOffset = (x * Math.sin(theta)) + (y * Math.cos(theta));
|
|
2101
|
+
var bulletCenterOffset = [-radius * Math.sqrt(2) / 2, -radius * Math.sqrt(2) / 2];
|
|
2102
|
+
bullet.set({
|
|
2103
|
+
radius: radius,
|
|
2104
|
+
fill: color,
|
|
2105
|
+
left: fabricText.left + xOffset + bulletCenterOffset[0],
|
|
2106
|
+
top: fabricText.top + yOffset + bulletCenterOffset[1]
|
|
2107
|
+
});
|
|
2114
2108
|
}
|
|
2115
2109
|
originalRenderTextLine.apply(fabricText, [method, ctx, line, left, top, lineIndex]);
|
|
2116
2110
|
};
|
|
@@ -2478,7 +2472,6 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2478
2472
|
this.updateCanvasDimensions(dimensions, this.zoom$.value);
|
|
2479
2473
|
this.dimensions$.next(dimensions);
|
|
2480
2474
|
this.onDimensionsChange();
|
|
2481
|
-
this.notifyObjectListChanged();
|
|
2482
2475
|
};
|
|
2483
2476
|
/**
|
|
2484
2477
|
* @override
|
|
@@ -2487,7 +2480,6 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2487
2480
|
AbstractInteractiveCanvas.prototype.setBaseDimensions = function (dimensions) {
|
|
2488
2481
|
this.baseDimensions = dimensions;
|
|
2489
2482
|
this.setDimensions(dimensions);
|
|
2490
|
-
this.notifyObjectListChanged();
|
|
2491
2483
|
};
|
|
2492
2484
|
/**
|
|
2493
2485
|
* @override
|