Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 45d33a3

Browse files
Chris van der Pennenrcreasey
authored andcommitted
Maintain zoom level across map redraws
1 parent 6cb9d3d commit 45d33a3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

app/js/SystemMap.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,13 @@ var SystemMap = {
148148
});
149149
});
150150

151+
var scale = 1;
152+
if( SystemMap.zoom ) scale = SystemMap.zoom.scale();
151153

152154
SystemMap.zoom = d3.behavior.zoom()
153155
.scaleExtent([0.4, 1])
154-
.on("zoom", zoomHandler);
156+
.on("zoom", zoomHandler)
157+
.scale(scale);
155158

156159
var root = svg.append("g");
157160

@@ -237,7 +240,6 @@ var SystemMap = {
237240
}
238241
force.stop();
239242

240-
var scale = SystemMap.zoom.scale();
241243
SystemMap.zoom.translate([(Data.ui.map.width() / 2 - nodes[system.id].x * scale), (Data.ui.map.height() / 2 - nodes[system.id].y * scale)]);
242244
SystemMap.zoom.event(root);
243245
},

0 commit comments

Comments
 (0)