From 201c74d29be97f441c74ac43e53626f9f98f3c0e Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Sat, 30 Dec 2017 20:01:00 +0100 Subject: [PATCH] [TASK] Add zoom modifier for forcegraph --- config.default.js | 3 ++- lib/forcegraph.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config.default.js b/config.default.js index 22b031d..6b42aff 100644 --- a/config.default.js +++ b/config.default.js @@ -155,7 +155,8 @@ module.exports = function () { 'highlightColor': 'rgba(255, 255, 255, 0.2)', 'labelColor': '#fff', 'tqFrom': '#770038', - 'tqTo': '#dc0067' + 'tqTo': '#dc0067', + 'zoomModifier': 1 }, 'locate': { 'outerCircle': { diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 6feb75d..39a8dfa 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -236,7 +236,7 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease', self.resetView = function resetView() { moveTo(function calcToReset() { draw.setHighlight(null); - return [0, 0, (ZOOM_MIN + 1) / 2]; + return [0, 0, (ZOOM_MIN + config.forceGraph.zoomModifier) / 2]; }, true); }; @@ -247,7 +247,7 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease', if (n) { return [n.x, n.y, (ZOOM_MAX + 1) / 2]; } - return [0, 0, (ZOOM_MIN + 1) / 2]; + return resetView(); }); }; @@ -260,7 +260,7 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease', if (l) { return [(l.source.x + l.target.x) / 2, (l.source.y + l.target.y) / 2, (ZOOM_MAX / 2) + ZOOM_MIN]; } - return [0, 0, (ZOOM_MIN + 1) / 2]; + return resetView(); }); };