Skip to content

Commit 8fa3fa1

Browse files
committed
fix issues with box quad
1 parent 8e0bfae commit 8fa3fa1

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

packages/web-component-designer/src/elements/helper/getBoxQuads.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ export function getElementSize(node, matrix) {
313313
function getElementOffsetsInContainer(node, includeScroll, iframes) {
314314
if ((node instanceof HTMLElement || node instanceof (node.ownerDocument.defaultView ?? window).HTMLElement)) {
315315
let cs = getCachedComputedStyle(node);
316-
if (cs.offsetPath && cs.offsetPath !== 'none') {
316+
/*if (cs.offsetPath && cs.offsetPath !== 'none') {
317317
return new DOMPoint(0, 0);
318-
}
318+
}*/
319319
if (includeScroll) {
320320
const cs = getCachedComputedStyle(node);
321321
return new DOMPoint(node.offsetLeft - (includeScroll ? node.scrollLeft - parseFloat(cs.borderLeftWidth) : 0), node.offsetTop - (includeScroll ? node.scrollTop - parseFloat(cs.borderTopWidth) : 0));
@@ -393,10 +393,37 @@ export function getResultingTransformationBetweenElementAndAllAncestors(node, an
393393
let parentElement = getParentElementIncludingSlots(actualElement, iframes);
394394

395395
if (actualElement.assignedSlot != null) {
396+
const st = getCachedComputedStyle(actualElement);
397+
if (st.position !== "static") {
398+
const mvMat = new DOMMatrix().translate(parseFloat(st.left), parseFloat(st.top));
399+
originalElementAndAllParentsMultipliedMatrix = mvMat.multiply(originalElementAndAllParentsMultipliedMatrix);
400+
}
401+
/*
402+
403+
following code should be used instead of above to fix:
404+
405+
406+
407+
but it does not work with:
408+
409+
<div>
410+
<visu-tag-root-canvas id="outer-tag-root-canvas" tag-root="SRM.RBG01">
411+
<template shadowrootmode="open">
412+
<div id="rootObj" style="height:100%;width:100%;position:absolute;top:400px;">
413+
<slot></slot>
414+
</div>
415+
</template>
416+
<div class="wrapper" id="aaaaabb" style="height:50px;width:50px;"></div>
417+
</visu-tag-root-canvas>
418+
</div>
419+
420+
*/
421+
/*
396422
const l = offsetTopLeftPolyfill(actualElement, 'offsetLeft');
397423
const t = offsetTopLeftPolyfill(actualElement, 'offsetTop');
398424
const mvMat = new DOMMatrix().translateSelf(l, t);
399425
originalElementAndAllParentsMultipliedMatrix = mvMat.multiplySelf(originalElementAndAllParentsMultipliedMatrix);
426+
*/
400427
} else {
401428
if (!(actualElement instanceof SVGSVGElement) && !(actualElement instanceof (actualElement.ownerDocument.defaultView ?? window).SVGSVGElement) &&
402429
(actualElement instanceof SVGGraphicsElement || actualElement instanceof (actualElement.ownerDocument.defaultView ?? window).SVGGraphicsElement)) {
@@ -1302,14 +1329,10 @@ function isElement(value) {
13021329

13031330
/**
13041331
*
1305-
* @param {Element | CSSStyleDeclaration} elementOrCss
1332+
* @param {CSSStyleDeclaration} css
13061333
* @returns {boolean}
13071334
*/
1308-
function isContainingBlock(elementOrCss) {
1309-
/** @type {CSSStyleDeclaration } */
1310-
//@ts-ignore
1311-
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1312-
1335+
function isContainingBlock(css) {
13131336
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
13141337
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
13151338
return (

0 commit comments

Comments
 (0)