fix source and target updates

This commit is contained in:
“chrisshank” 2024-12-10 11:31:50 -08:00
parent fb3895e0d4
commit fabc27200c
4 changed files with 8 additions and 3 deletions

View File

@ -31,6 +31,7 @@
<body>
<folk-shape id="box1" x="50" y="100" width="50" height="50"></folk-shape>
<folk-shape id="box2" x="150" y="300" width="50" height="50"></folk-shape>
<folk-shape id="box3" x="200" y="200" width="50" height="50"></folk-shape>
<folk-arrow source="#box1" target="#box2"></folk-arrow>
<script type="module">

View File

@ -61,9 +61,12 @@ export class FolkArrow extends FolkBaseConnection {
if (sourceRect === null || targetRect === null) {
this.style.clipPath = '';
this.style.display = 'none';
return;
}
this.style.display = 'block';
const [sx, sy, cx, cy, ex, ey] = getBoxToBoxArrow(
sourceRect.x,
sourceRect.y,

View File

@ -26,8 +26,8 @@ export class FolkBaseConnection extends FolkElement {
this.unobserveTarget();
}
override update(changedProperties: PropertyValues<this>) {
super.update(changedProperties);
override willUpdate(changedProperties: PropertyValues<this>) {
super.willUpdate(changedProperties);
if (changedProperties.has('source')) {
this.observeSource();

View File

@ -160,9 +160,10 @@ to.${key} = ${value};`);
}
#evaluateExpression = (event?: Event) => {
console.log('eval');
if (this.sourceElement === null || this.targetElement === null) return;
this.stroke = 'black';
if (!this.#function) return;
try {