Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
exetico committed Dec 3, 2023
2 parents 532fe8b + 5db8228 commit bd68d67
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ jobs:
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
branch: ${{ github.ref_name }}
5 changes: 2 additions & 3 deletions dist/floorplan-examples.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/floorplan.js

Large diffs are not rendered by default.

60 changes: 33 additions & 27 deletions docs/_docs/floorplan/floorplan-examples.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ha-floorplan",
"version": "1.0.37",
"version": "1.0.40",
"description": "Floorplan for Home Assistant",
"homepage": "https://experiencelovelace.github.io/ha-floorplan",
"keywords": [
Expand Down Expand Up @@ -63,4 +63,4 @@
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1"
}
}
}
15 changes: 10 additions & 5 deletions src/components/floorplan/floorplan-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,14 @@ export class FloorplanElement extends LitElement {

svg.id = svgElementInfo.svgElement.id;
svg.setAttribute('preserveAspectRatio', 'xMinYMin meet');
svg.setAttribute('height', svgElementInfo.originalBBox.height.toString());
svg.setAttribute('width', svgElementInfo.originalBBox.width.toString());
svg.setAttribute('x', svgElementInfo.originalBBox.x.toString());
svg.setAttribute('y', svgElementInfo.originalBBox.y.toString());

// A clipPath does not have the clipPath function on the element, therefore originalBBox can be null in some cases
if(svgElementInfo.originalBBox !== null){
svg.setAttribute('height', svgElementInfo.originalBBox.height.toString());
svg.setAttribute('width', svgElementInfo.originalBBox.width.toString());
svg.setAttribute('x', svgElementInfo.originalBBox.x.toString());
svg.setAttribute('y', svgElementInfo.originalBBox.y.toString());
}

if (svgElementInfo.svgElement.nodeName !== 'g') {
const originalTransform =
Expand Down Expand Up @@ -1334,7 +1338,8 @@ export class FloorplanElement extends LitElement {
svgElement.id,
svgElement,
svgElement,
svgElement.getBBox()
// A clipPath does not have the clipPath function
svgElement.getBBox ? svgElement.getBBox() : null
);
ruleInfo.svgElementInfos[svgElement.id] = svgElementInfo;

Expand Down
2 changes: 1 addition & 1 deletion src/components/floorplan/lib/floorplan-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class FloorplanSvgElementInfo {
public entityId: string,
public svgElement: SVGGraphicsElement,
public originalSvgElement: SVGGraphicsElement,
public originalBBox: DOMRect
public originalBBox: DOMRect | null,
) { }
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class Utils {
textElement.textContent = '';

// Note the user about the intended change in a dataset
textElement.dataset.ha_floorplan_notice = 'The text_set function splitted your text into multiple tspans. Only the style of the first tspan is preserved. The style from the original tspan is reused on every tspan. The x and y are calculated on basis of the first tspan or text-element.';
textElement.dataset.ha_floorplan_notice = 'The text_set function split your text into multiple tspans. Only the style of the first tspan is preserved. The style from the original tspan is reused on every tspan. The x and y are calculated on the basis of the first tspan or text-element.';

// Get x location of text, if no found, set to 0
const textXPosition = textElement.getAttribute('x') || '0';
Expand Down Expand Up @@ -394,4 +394,4 @@ export class Utils {
}
return localStorage[ID_BROWER_KEY];
}
}
}

0 comments on commit bd68d67

Please sign in to comment.