@statelyai/flow-dom 3.4.5 → 3.4.7
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.
- package/dist/esm/index.js +26 -4
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -414,13 +414,22 @@ function createEntityGeometryObserver(store, options = {}) {
|
|
|
414
414
|
});
|
|
415
415
|
},
|
|
416
416
|
observeEdge(element, target) {
|
|
417
|
+
const inferredSegments = /* @__PURE__ */ new WeakMap();
|
|
417
418
|
return observe(target.id, () => {
|
|
418
419
|
const pathData = target.getPathData();
|
|
419
420
|
if (!pathData) return;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const
|
|
423
|
-
|
|
421
|
+
const svgSegments = pathData.segments.map(pathToSVG);
|
|
422
|
+
element.querySelectorAll("path").forEach((path) => {
|
|
423
|
+
const explicitIndex = path.dataset.flowEdgeSegment;
|
|
424
|
+
let index = explicitIndex === void 0 ? inferredSegments.get(path) : Number(explicitIndex);
|
|
425
|
+
if (index === void 0) {
|
|
426
|
+
const matchedIndex = svgSegments.indexOf(path.getAttribute("d") ?? "");
|
|
427
|
+
if (matchedIndex < 0) return;
|
|
428
|
+
index = matchedIndex;
|
|
429
|
+
inferredSegments.set(path, index);
|
|
430
|
+
}
|
|
431
|
+
const segment = svgSegments[index];
|
|
432
|
+
if (segment !== void 0) path.setAttribute("d", segment);
|
|
424
433
|
});
|
|
425
434
|
const first = pathData.segments[0]?.points[0];
|
|
426
435
|
const last = pathData.segments.at(-1)?.points.at(-1);
|
|
@@ -590,11 +599,24 @@ function attachContainer(store, element, options = {}) {
|
|
|
590
599
|
preserveCenter: options.preserveViewportCenter
|
|
591
600
|
});
|
|
592
601
|
};
|
|
602
|
+
const onScroll = (event) => {
|
|
603
|
+
if (event.target !== element) return;
|
|
604
|
+
const { scrollLeft, scrollTop } = element;
|
|
605
|
+
if (!scrollLeft && !scrollTop) return;
|
|
606
|
+
element.scrollLeft = 0;
|
|
607
|
+
element.scrollTop = 0;
|
|
608
|
+
store.trigger.panBy({
|
|
609
|
+
x: -scrollLeft,
|
|
610
|
+
y: -scrollTop
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
element.addEventListener("scroll", onScroll);
|
|
593
614
|
update();
|
|
594
615
|
const observer = new ((element.ownerDocument.defaultView?.ResizeObserver) ?? ResizeObserver)(update);
|
|
595
616
|
observer.observe(element);
|
|
596
617
|
return () => {
|
|
597
618
|
if (containers.get(store) === element) containers.delete(store);
|
|
619
|
+
element.removeEventListener("scroll", onScroll);
|
|
598
620
|
observer.disconnect();
|
|
599
621
|
};
|
|
600
622
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statelyai/flow-dom",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.7",
|
|
4
4
|
"description": "DOM-specific helpers for @statelyai/flow with core re-exports.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@statelyai/flow": "0.
|
|
30
|
+
"@statelyai/flow": "0.11.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@vitest/coverage-v8": "^4.1.0",
|