@node-projects/web-component-designer 0.0.98 → 0.0.99

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.
@@ -135,7 +135,11 @@ export class CssCombiner {
135
135
  styles.delete('margin-right');
136
136
  styles.delete('margin-bottom');
137
137
  styles.delete('margin-left');
138
- styles.set('margin', e.style.marginTop + ' ' + e.style.marginRight + ' ' + e.style.marginBottom + ' ' + e.style.marginLeft);
138
+ if (e.style.marginTop == e.style.marginRight && e.style.marginTop == e.style.marginBottom && e.style.marginTop == e.style.marginLeft) {
139
+ styles.set('margin', e.style.marginTop);
140
+ }
141
+ else
142
+ styles.set('margin', e.style.marginTop + ' ' + e.style.marginRight + ' ' + e.style.marginBottom + ' ' + e.style.marginLeft);
139
143
  }
140
144
  }
141
145
  static combinePadding(styles) {
@@ -155,7 +159,11 @@ export class CssCombiner {
155
159
  styles.delete('padding-right');
156
160
  styles.delete('padding-bottom');
157
161
  styles.delete('padding-left');
158
- styles.set('padding', e.style.paddingTop + ' ' + e.style.paddingRight + ' ' + e.style.paddingBottom + ' ' + e.style.paddingLeft);
162
+ if (e.style.paddingTop == e.style.paddingRight && e.style.paddingTop == e.style.paddingBottom && e.style.paddingTop == e.style.paddingLeft) {
163
+ styles.set('padding', e.style.paddingTop);
164
+ }
165
+ else
166
+ styles.set('padding', e.style.paddingTop + ' ' + e.style.paddingRight + ' ' + e.style.paddingBottom + ' ' + e.style.paddingLeft);
159
167
  }
160
168
  }
161
169
  static combineInset(styles) {
@@ -1,7 +1,8 @@
1
1
  export function CalculateGridInformation(designItem) {
2
2
  //todo:
3
3
  //same name should combine columns/rows
4
- let itemRect = designItem.element.getBoundingClientRect();
4
+ let itemRect = designItem.instanceServiceContainer.designerCanvas.getNormalizedElementCoordinates(designItem.element);
5
+ //let itemRect = designItem.element.getBoundingClientRect();
5
6
  const computedStyle = getComputedStyle(designItem.element);
6
7
  const rows = computedStyle.gridTemplateRows.split(' ');
7
8
  const columns = computedStyle.gridTemplateColumns.split(' ');
@@ -11,8 +12,8 @@ export function CalculateGridInformation(designItem) {
11
12
  let xGap = 0;
12
13
  let yGap = 0;
13
14
  let rw = 0;
14
- let xOffset = itemRect.x - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.x;
15
- let yOffset = itemRect.y - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.y;
15
+ let xOffset = itemRect.x; // - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.x;
16
+ let yOffset = itemRect.y; // - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.y;
16
17
  let gridA = null;
17
18
  if (computedStyle.gridTemplateAreas && computedStyle.gridTemplateAreas !== 'none')
18
19
  gridA = computedStyle.gridTemplateAreas.split('\"');
@@ -243,7 +243,9 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
243
243
  scaleX = cvRect.width / dimensions.width;
244
244
  if (dimensions.height)
245
245
  scaleY = cvRect.height / dimensions.height;
246
- this._designerCanvas.zoomFactor = scaleX < scaleY ? scaleX : scaleY;
246
+ let fak = scaleX < scaleY ? scaleX : scaleY;
247
+ if (!isNaN(fak))
248
+ this._designerCanvas.zoomFactor = fak;
247
249
  this._zoomInput.value = Math.round(this._designerCanvas.zoomFactor * 100) + '%';
248
250
  }
249
251
  _onScrollbar(e) {
@@ -4,19 +4,17 @@ export class CanvasExtension extends AbstractExtension {
4
4
  super(extensionManager, designerView, extendedItem);
5
5
  }
6
6
  extend() {
7
- let itemRect = this.extendedItem.element.getBoundingClientRect();
7
+ let itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
8
8
  const computedStyle = getComputedStyle(this.extendedItem.element);
9
9
  if (computedStyle.margin !== '0px') {
10
- const xOffset = itemRect.x - this.designerCanvas.containerBoundingRect.x;
11
- const yOffset = itemRect.y - this.designerCanvas.containerBoundingRect.y;
12
10
  const left = Number.parseFloat(computedStyle.marginLeft.replace('px', ''));
13
11
  const top = Number.parseFloat(computedStyle.marginTop.replace('px', ''));
14
12
  const right = Number.parseFloat(computedStyle.marginRight.replace('px', ''));
15
13
  const bottom = Number.parseFloat(computedStyle.marginBottom.replace('px', ''));
16
- this._drawRect(xOffset - left, yOffset - top, left + itemRect.width + right, top, 'svg-margin');
17
- this._drawRect(xOffset - left, yOffset, left, itemRect.height, 'svg-margin');
18
- this._drawRect(xOffset + itemRect.width, yOffset, right, itemRect.height, 'svg-margin');
19
- this._drawRect(xOffset - left, yOffset + itemRect.height, left + itemRect.width + right, bottom, 'svg-margin');
14
+ this._drawRect(itemRect.x - left, itemRect.y - top, left + itemRect.width + right, top, 'svg-margin');
15
+ this._drawRect(itemRect.x - left, itemRect.y, left, itemRect.height, 'svg-margin');
16
+ this._drawRect(itemRect.x + itemRect.width, itemRect.y, right, itemRect.height, 'svg-margin');
17
+ this._drawRect(itemRect.x - left, itemRect.y + itemRect.height, left + itemRect.width + right, bottom, 'svg-margin');
20
18
  }
21
19
  }
22
20
  refresh() {
@@ -1,4 +1,5 @@
1
1
  import { AbstractExtension } from "./AbstractExtension";
2
+ import { OverlayLayer } from "./OverlayLayer.js";
2
3
  export class GrayOutExtension extends AbstractExtension {
3
4
  _path;
4
5
  constructor(extensionManager, designerView, extendedItem) {
@@ -11,7 +12,7 @@ export class GrayOutExtension extends AbstractExtension {
11
12
  if (!this._path) {
12
13
  this._path = document.createElementNS("http://www.w3.org/2000/svg", "path");
13
14
  this._path.setAttribute('class', 'svg-gray-out');
14
- this.overlayLayerView.appendChild(this._path);
15
+ this.overlayLayerView.addOverlay(this._path, OverlayLayer.Background);
15
16
  this.overlays.push(this._path);
16
17
  }
17
18
  let itemRect = this.extendedItem.element.getBoundingClientRect();
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.98",
4
+ "version": "0.0.99",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",