@node-projects/web-component-designer 0.0.200 → 0.0.202

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.
@@ -12,6 +12,6 @@ export declare class EditGridColumnRowSizesExtension extends AbstractExtension {
12
12
  extend(event?: Event): void;
13
13
  refresh(event?: Event): void;
14
14
  _pointerActionTypeResize(event: PointerEvent, rect: SVGRectElement, gap: ReturnType<typeof CalculateGridInformation>['gaps'][0]): void;
15
- _convertCssUnitIncludingFr(cssValue: string | number, target: HTMLElement, percentTarget: 'width' | 'height', unit: string, units: string[]): string;
15
+ _convertCssUnits(pixelSizes: number[], targetUnits: string[], target: HTMLElement, percentTarget: 'width' | 'height'): string[];
16
16
  dispose(): void;
17
17
  }
@@ -68,42 +68,38 @@ export class EditGridColumnRowSizesExtension extends AbstractExtension {
68
68
  units = initialParts.map(x => getCssUnit(x));
69
69
  }
70
70
  this.extendedItem.element.style[templatePropertyName] = '';
71
- const unit1 = units[index];
72
- initialParts[index] = this._convertCssUnitIncludingFr(parseFloat(initialParts[index]) - diff, this.extendedItem.element, sizeType, unit1, units);
73
- const unit2 = units[index + 1];
74
- initialParts[index + 1] = this._convertCssUnitIncludingFr(parseFloat(initialParts[index + 1]) + diff, this.extendedItem.element, sizeType, unit2, units);
75
- this.extendedItem.updateStyleInSheetOrLocal(templatePropertyName, initialParts.join(' '));
71
+ const targetPixelSizes = initialParts.map(x => parseFloat(x));
72
+ targetPixelSizes[index] -= diff;
73
+ targetPixelSizes[index + 1] += diff;
74
+ const newSizes = this._convertCssUnits(targetPixelSizes, units, this.extendedItem.element, sizeType);
75
+ this.extendedItem.updateStyleInSheetOrLocal(templatePropertyName, newSizes.join(' '));
76
76
  this._initalPos = null;
77
77
  this._initialSizes = null;
78
78
  this.extensionManager.refreshExtensions([this.extendedItem]);
79
79
  break;
80
80
  }
81
81
  }
82
- _convertCssUnitIncludingFr(cssValue, target, percentTarget, unit, units) {
83
- if (unit == "fr") {
84
- let containerSize = convertCssUnitToPixel(target.style.width, target, percentTarget);
85
- let amountGaps = percentTarget == "height" ? this.gridInformation.cells.length - 1 : this.gridInformation.cells[0].length - 1;
86
- let gapSize = convertCssUnitToPixel(percentTarget == "width" ? target.style.columnGap : target.style.rowGap, target, percentTarget) ?? 0;
87
- let containerSizeWithoutGaps = containerSize - gapSize * amountGaps;
88
- let amountFrSizes = 0;
89
- let leftOver = containerSizeWithoutGaps;
90
- this.gridInformation.cells[0].forEach((column, i) => {
91
- if (units[i] == "fr")
92
- amountFrSizes++;
93
- else
94
- leftOver -= column[percentTarget];
95
- });
96
- let frRatio = leftOver / amountFrSizes;
97
- if (typeof cssValue == "number") {
98
- //expected Value in Pixel
99
- return (cssValue / frRatio).toFixed(2) + "fr";
82
+ _convertCssUnits(pixelSizes, targetUnits, target, percentTarget) {
83
+ let bounding = target.getBoundingClientRect();
84
+ let containerSize = bounding[percentTarget];
85
+ let amountGaps = percentTarget == "height" ? this.gridInformation.cells.length - 1 : this.gridInformation.cells[0].length - 1;
86
+ let gapSize = convertCssUnitToPixel(percentTarget == "width" ? target.style.columnGap : target.style.rowGap, target, percentTarget) ?? 0;
87
+ let containerSizeWithoutGaps = containerSize - gapSize * amountGaps;
88
+ let sizeForFrs = containerSizeWithoutGaps;
89
+ for (let i = 0; i < pixelSizes.length; i++) {
90
+ if (targetUnits[i] != 'fr')
91
+ sizeForFrs -= pixelSizes[i];
92
+ }
93
+ let result = [];
94
+ for (let i = 0; i < pixelSizes.length; i++) {
95
+ if (targetUnits[i] != 'fr') {
96
+ result.push(convertCssUnit(pixelSizes[i], target, percentTarget, targetUnits[i]));
100
97
  }
101
98
  else {
102
- return (convertCssUnitToPixel(cssValue, target, percentTarget) / frRatio).toFixed(2) + "fr";
99
+ result.push((pixelSizes[i] / sizeForFrs).toFixed(2) + 'fr');
103
100
  }
104
101
  }
105
- else
106
- return convertCssUnit(cssValue, target, percentTarget, unit);
102
+ return result;
107
103
  }
108
104
  dispose() {
109
105
  this._removeAllOverlays();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A UI designer for Polymer apps",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.0.200",
4
+ "version": "0.0.202",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",