Updated taggedRect

This commit is contained in:
saurabhg772244 2024-08-16 18:57:56 +05:30
parent d30444dae7
commit 763a0c0d83
2 changed files with 14 additions and 13 deletions

View File

@ -24,10 +24,10 @@ export const taggedRect = async (parent: SVGAElement, node: Node) => {
const options = userNodeOverrides(node, {});
const rectPoints = [
{ x, y },
{ x: x - tagWidth, y },
{ x: x + w, y },
{ x: x + w, y: y + h },
{ x, y: y + h },
{ x: x - tagWidth, y: y + h },
];
const tagPoints = [
@ -48,8 +48,8 @@ export const taggedRect = async (parent: SVGAElement, node: Node) => {
const tagNode = rc.path(tagPath, options);
const taggedRect = shapeSvg.insert('g', ':first-child');
taggedRect.insert(() => tagNode, ':first-child');
taggedRect.insert(() => rectNode, ':first-child');
taggedRect.insert(() => tagNode);
taggedRect.attr('class', 'basic label-container');
@ -60,11 +60,12 @@ export const taggedRect = async (parent: SVGAElement, node: Node) => {
if (nodeStyles) {
taggedRect.attr('style', nodeStyles);
}
taggedRect.attr('transform', `translate(${tagWidth / 2}, 0)`);
updateNodeBounds(node, taggedRect);
node.intersect = function (point) {
const pos = intersect.rect(node, point);
const pos = intersect.polygon(node, rectPoints, point);
return pos;
};

View File

@ -51,20 +51,20 @@ export const windowPane = async (parent: SVGAElement, node: Node) => {
const innerSecondPath = createPathFromPoints(innerSecondPathPoints);
const innerSecondNode = rc.path(innerSecondPath, options);
const taggedRect = shapeSvg.insert('g', ':first-child');
taggedRect.insert(() => innerNode, ':first-child');
taggedRect.insert(() => innerSecondNode, ':first-child');
taggedRect.insert(() => outerNode, ':first-child');
taggedRect.attr('transform', `translate(${rectOffset / 2}, ${rectOffset / 2})`);
const windowPane = shapeSvg.insert('g', ':first-child');
windowPane.insert(() => innerNode, ':first-child');
windowPane.insert(() => innerSecondNode, ':first-child');
windowPane.insert(() => outerNode, ':first-child');
windowPane.attr('transform', `translate(${rectOffset / 2}, ${rectOffset / 2})`);
taggedRect.attr('class', 'basic label-container');
windowPane.attr('class', 'basic label-container');
if (cssStyles) {
taggedRect.attr('style', cssStyles);
windowPane.attr('style', cssStyles);
}
if (nodeStyles) {
taggedRect.attr('style', nodeStyles);
windowPane.attr('style', nodeStyles);
}
label.attr(
@ -72,7 +72,7 @@ export const windowPane = async (parent: SVGAElement, node: Node) => {
`translate(${-(bbox.width / 2) + rectOffset / 2}, ${-(bbox.height / 2) + rectOffset / 2})`
);
updateNodeBounds(node, taggedRect);
updateNodeBounds(node, windowPane);
node.intersect = function (point) {
const pos = intersect.polygon(node, outerPathPoints, point);