@lancom/shared 0.0.315 → 0.0.317
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.
|
@@ -136,12 +136,12 @@ export default class FabricHelper {
|
|
|
136
136
|
|
|
137
137
|
setPrintArea(printArea, size, product) {
|
|
138
138
|
this.printAreaRect = getPrintAreaByName({
|
|
139
|
-
printArea: printArea?._id,
|
|
139
|
+
printArea: printArea?.parentPrintArea || printArea?._id,
|
|
140
140
|
printSize: printArea?.printSize,
|
|
141
141
|
printAreaOffsets: printArea?.printAreaOffsets,
|
|
142
142
|
editorWidth: size.width,
|
|
143
143
|
editorHeight: size.height
|
|
144
|
-
}, product);
|
|
144
|
+
}, product, true);
|
|
145
145
|
if (this.background) {
|
|
146
146
|
this.background.setBoundingRect(this.printAreaRect);
|
|
147
147
|
}
|
|
@@ -9,9 +9,9 @@ export function generateLayersTemplate(template, printArea) {
|
|
|
9
9
|
|
|
10
10
|
export function fitLayerToEditorSize(layer, { size }, printArea) {
|
|
11
11
|
const { width, height, top, left } = printArea;
|
|
12
|
-
const scaleKoef = width / size.width;
|
|
13
|
-
layer.top = top + layer.top * scaleKoef
|
|
14
|
-
layer.left = left + layer.left * scaleKoef
|
|
12
|
+
const scaleKoef = Math.min(height / size.height, width / size.width);
|
|
13
|
+
layer.top = top + layer.top * scaleKoef + (height - size.height * scaleKoef) / 2;
|
|
14
|
+
layer.left = left + layer.left * scaleKoef + (width - size.width * scaleKoef) / 2;
|
|
15
15
|
['fontSize', 'scaleX', 'scaleY'].forEach(property => {
|
|
16
16
|
if (property in layer) {
|
|
17
17
|
const originalSize = layer[property];
|
|
@@ -164,6 +164,6 @@ export function getAllPrintAreas(product) {
|
|
|
164
164
|
?.reduce((options, pa) => [
|
|
165
165
|
...options,
|
|
166
166
|
pa,
|
|
167
|
-
...pa.sizes
|
|
167
|
+
...(pa.sizes?.map(s => ({ ...s, side: pa.side, parentPrintArea: pa._id })) || [])
|
|
168
168
|
], []) || [];
|
|
169
169
|
}
|