@lancom/shared 0.0.315 → 0.0.316

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.
@@ -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 - 5 + (height - size.height * scaleKoef) / 2;
14
- layer.left = left + layer.left * scaleKoef - 5 + (width - size.width * scaleKoef) / 2;
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.map(s => ({ ...s, side: pa.side, parentPrintArea: pa._id }))
167
+ ...(pa.sizes?.map(s => ({ ...s, side: pa.side, parentPrintArea: pa._id })) || [])
168
168
  ], []) || [];
169
169
  }
@@ -98,8 +98,7 @@ export default {
98
98
  type: Object
99
99
  },
100
100
  printAreaSize: {
101
- type: String | Object,
102
- required: true
101
+ type: String | Object
103
102
  },
104
103
  zoomSize: {
105
104
  type: Number
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.315",
3
+ "version": "0.0.316",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {