From e279a0acf00c18f34f1032028ecd54223c60d2c4 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Wed, 23 Feb 2022 16:26:42 +0100 Subject: [PATCH] finally fix zoom issue --- docs/morphisms/js/d3_visualisation.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/morphisms/js/d3_visualisation.js b/docs/morphisms/js/d3_visualisation.js index 5543cc5..7c7a1f0 100644 --- a/docs/morphisms/js/d3_visualisation.js +++ b/docs/morphisms/js/d3_visualisation.js @@ -152,15 +152,16 @@ async function create_svg( } d3.select("input").on("input", function () { - let n = nodes.find(n => n.id == this.value) + let id = this.value; + let n = nodes.find(n => n.id == id) if (n) { - foreground_descendants(n.id) - // let transform = {k:1, x:n.x, y:n.y} - console.log(n) + foreground_descendants(id) - d3.zoom().translateTo(svg_content,n.x, n.y) - // console.log(transform) - // svg_content.attr("transform", `translate(${n.x/2},${n.y/2})`) + svg.transition() + .duration(750) + .call(zoom.transform, d3.zoomIdentity); + + zoom.translateTo(svg.transition().duration(750), n.x, n.y) } });