react-design-editor 0.0.54 → 0.0.55
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.
|
@@ -28,7 +28,23 @@ class AlignmentHandler {
|
|
|
28
28
|
const activeSelection = activeObject;
|
|
29
29
|
activeSelection.forEachObject(obj => {
|
|
30
30
|
obj.set({
|
|
31
|
-
left: 0 - (
|
|
31
|
+
left: 0 - (obj.width * obj.scaleX) / 2,
|
|
32
|
+
});
|
|
33
|
+
obj.setCoords();
|
|
34
|
+
this.handler.canvas.renderAll();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Align center at selection
|
|
40
|
+
*/
|
|
41
|
+
this.middle = () => {
|
|
42
|
+
const activeObject = this.handler.canvas.getActiveObject();
|
|
43
|
+
if (activeObject && activeObject.type === 'activeSelection') {
|
|
44
|
+
const activeSelection = activeObject;
|
|
45
|
+
activeSelection.forEachObject(obj => {
|
|
46
|
+
obj.set({
|
|
47
|
+
top: 0 - (obj.width * obj.scaleX) / 2,
|
|
32
48
|
});
|
|
33
49
|
obj.setCoords();
|
|
34
50
|
this.handler.canvas.renderAll();
|
|
@@ -42,10 +58,10 @@ class AlignmentHandler {
|
|
|
42
58
|
const activeObject = this.handler.canvas.getActiveObject();
|
|
43
59
|
if (activeObject && activeObject.type === 'activeSelection') {
|
|
44
60
|
const activeSelection = activeObject;
|
|
45
|
-
const activeObjectLeft =
|
|
61
|
+
const activeObjectLeft = activeObject.width / 2;
|
|
46
62
|
activeSelection.forEachObject(obj => {
|
|
47
63
|
obj.set({
|
|
48
|
-
left: activeObjectLeft -
|
|
64
|
+
left: activeObjectLeft - obj.width * obj.scaleX,
|
|
49
65
|
});
|
|
50
66
|
obj.setCoords();
|
|
51
67
|
this.handler.canvas.renderAll();
|
package/lib/handlers/Handler.js
CHANGED
|
@@ -358,6 +358,7 @@ class Handler {
|
|
|
358
358
|
obj.set('src', source);
|
|
359
359
|
resolve(obj.setSrc(source, () => this.canvas.renderAll(), {
|
|
360
360
|
dirty: true,
|
|
361
|
+
crossOrigin: "anonymous"
|
|
361
362
|
}));
|
|
362
363
|
}
|
|
363
364
|
});
|
|
@@ -1476,8 +1477,13 @@ class Handler {
|
|
|
1476
1477
|
this.saveCanvasImage = (option = { name: 'New Image', format: 'png', quality: 1 }) => {
|
|
1477
1478
|
// If it's zoomed out/in, the container will also include in the image
|
|
1478
1479
|
// hence need to reset the zoom level.
|
|
1479
|
-
this.
|
|
1480
|
-
|
|
1480
|
+
let { left, top, width, height, scaleX, scaleY } = this.workarea;
|
|
1481
|
+
width = Math.ceil(width * scaleX);
|
|
1482
|
+
height = Math.ceil(height * scaleY);
|
|
1483
|
+
// cachedVT is used to reset the viewportTransform after the image is saved.
|
|
1484
|
+
const cachedVT = this.canvas.viewportTransform;
|
|
1485
|
+
// reset the viewportTransform to default (no zoom)
|
|
1486
|
+
this.canvas.viewportTransform = [1, 0, 0, 1, 0, 0];
|
|
1481
1487
|
const dataUrl = this.canvas.toDataURL({
|
|
1482
1488
|
...option,
|
|
1483
1489
|
left,
|
|
@@ -1494,6 +1500,8 @@ class Handler {
|
|
|
1494
1500
|
anchorEl.click();
|
|
1495
1501
|
anchorEl.remove();
|
|
1496
1502
|
}
|
|
1503
|
+
// reset the viewportTransform to previous value.
|
|
1504
|
+
this.canvas.viewportTransform = cachedVT;
|
|
1497
1505
|
};
|
|
1498
1506
|
/**
|
|
1499
1507
|
* Sets "angle" of an instance with centered rotation
|