Move cardToMiddle vertical-centering fix into the family-chart patch
Fold the fly-to vertical-centering fix into our patch-package patch (alongside the existing spouse-layout fix) instead of compensating in app code, and revert the in-app workaround so the two don't double-correct. - patches/family-chart+0.9.0.patch: cardToMiddle now scales datum.y by the zoom k in both dist builds (.js + .esm.js), matching datum.x. Verified the patch applies cleanly (patch-package --error-on-fail). - tree/page.tsx: the cardToMiddle caller passes raw y again (the patched library does the scaling now); pre-scaling here too would double-correct. Behavior is identical to the previous in-app fix — both center the node exactly. - CLAUDE.md: documents the two family-chart patches, how to regenerate them, and that both should be upstreamed. The cardToMiddle fix is submitted upstream (donatso/family-chart#103, issue #102); the spouse-layout fix is a TODO. The frontend Dockerfile already COPYs patches/ before npm ci, so the fix is in the production build. Signed-off-by: Justin Paul <justin@jpaul.me>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
diff --git a/node_modules/family-chart/dist/family-chart.esm.js b/node_modules/family-chart/dist/family-chart.esm.js
|
||||
index 3867be0..560c99e 100644
|
||||
index 3867be0..656fafa 100644
|
||||
--- a/node_modules/family-chart/dist/family-chart.esm.js
|
||||
+++ b/node_modules/family-chart/dist/family-chart.esm.js
|
||||
@@ -10,10 +10,10 @@ function sortChildrenWithSpouses(children, datum, data) {
|
||||
@@ -61,8 +61,17 @@ index 3867be0..560c99e 100644
|
||||
if (!d.spouses)
|
||||
d.spouses = [];
|
||||
d.spouses.push(spouse);
|
||||
@@ -1073,7 +1091,7 @@ function calculateTreeFit(svg_dim, tree_dim) {
|
||||
return { k, x, y };
|
||||
}
|
||||
function cardToMiddle({ datum, svg, svg_dim, scale, transition_time }) {
|
||||
- const k = scale || 1, x = svg_dim.width / 2 - datum.x * k, y = svg_dim.height / 2 - datum.y, t = { k, x: x / k, y: y / k };
|
||||
+ const k = scale || 1, x = svg_dim.width / 2 - datum.x * k, y = svg_dim.height / 2 - datum.y * k, t = { k, x: x / k, y: y / k };
|
||||
positionTree({ t, svg, transition_time });
|
||||
}
|
||||
function manualZoom({ amount, svg, transition_time = 500 }) {
|
||||
diff --git a/node_modules/family-chart/dist/family-chart.js b/node_modules/family-chart/dist/family-chart.js
|
||||
index 1c750d4..47efcc2 100644
|
||||
index 1c750d4..edeb804 100644
|
||||
--- a/node_modules/family-chart/dist/family-chart.js
|
||||
+++ b/node_modules/family-chart/dist/family-chart.js
|
||||
@@ -33,10 +33,9 @@
|
||||
@@ -116,3 +125,12 @@ index 1c750d4..47efcc2 100644
|
||||
if (!d.spouses)
|
||||
d.spouses = [];
|
||||
d.spouses.push(spouse);
|
||||
@@ -1096,7 +1106,7 @@
|
||||
return { k, x, y };
|
||||
}
|
||||
function cardToMiddle({ datum, svg, svg_dim, scale, transition_time }) {
|
||||
- const k = scale || 1, x = svg_dim.width / 2 - datum.x * k, y = svg_dim.height / 2 - datum.y, t = { k, x: x / k, y: y / k };
|
||||
+ const k = scale || 1, x = svg_dim.width / 2 - datum.x * k, y = svg_dim.height / 2 - datum.y * k, t = { k, x: x / k, y: y / k };
|
||||
positionTree({ t, svg, transition_time });
|
||||
}
|
||||
function manualZoom({ amount, svg, transition_time = 500 }) {
|
||||
|
||||
Reference in New Issue
Block a user