From 9eca94bb6ca1fcca65baaad8b6031f68adac71db Mon Sep 17 00:00:00 2001 From: Brent Bovenzi Date: Wed, 16 Jun 2021 13:20:19 -0500 Subject: [PATCH] fix: change graph focus to top of view instead of center (#16484) (cherry picked from commit f1675853a5ed9b779ee2fc13bb9aa97185472bc7) --- airflow/www/static/js/graph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/www/static/js/graph.js b/airflow/www/static/js/graph.js index 6482d91a9089c..5d8ab8e71fc59 100644 --- a/airflow/www/static/js/graph.js +++ b/airflow/www/static/js/graph.js @@ -553,7 +553,6 @@ function focusedGroupKey() { function focusGroup(nodeId) { if (nodeId != null && zoom != null) { const { x } = g.node(nodeId); - const { y } = g.node(nodeId); // This is the total canvas size. const { width, height } = svg.node().getBoundingClientRect(); @@ -572,7 +571,8 @@ function focusGroup(nodeId) { 1.5, // cap zoom level to 1.5 so nodes are not too large ) * 0.9; - const [deltaX, deltaY] = [width / 2 - x * scale, height / 2 - y * scale]; + // deltaY of 5 keeps the zoom at the top of the view but with a slight margin + const [deltaX, deltaY] = [width / 2 - x * scale, 5]; zoom.translate([deltaX, deltaY]); zoom.scale(scale); zoom.event(innerSvg.transition().duration(duration));