Skip to content

Commit

Permalink
fix: change graph focus to top of view instead of center (#16484)
Browse files Browse the repository at this point in the history
(cherry picked from commit f167585)
  • Loading branch information
bbovenzi authored and jhtimmins committed Aug 17, 2021
1 parent ed6e0be commit 2507b42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions airflow/www/static/js/graph.js
Expand Up @@ -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();

Expand All @@ -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));
Expand Down

0 comments on commit 2507b42

Please sign in to comment.