mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor(es modules): continue migration
This commit is contained in:
parent
eaa0046e67
commit
4a04a8622d
23 changed files with 121 additions and 77 deletions
|
|
@ -22,6 +22,10 @@ window.Zoom = (function () {
|
|||
const onZoomDebouced = debounce(onZoom, 50);
|
||||
const zoom = d3.zoom().scaleExtent([1, 20]).on("zoom", onZoomDebouced);
|
||||
|
||||
function setZoomBehavior() {
|
||||
svg.call(zoom);
|
||||
}
|
||||
|
||||
// zoom to a specific point
|
||||
function to(x, y, z = 8, d = 2000) {
|
||||
const transform = d3.zoomIdentity.translate(x * -z + graphWidth / 2, y * -z + graphHeight / 2).scale(z);
|
||||
|
|
@ -48,5 +52,5 @@ window.Zoom = (function () {
|
|||
zoom.scaleTo(element, scale);
|
||||
}
|
||||
|
||||
return {to, reset, scaleExtent, translateExtent, scaleTo};
|
||||
return {setZoomBehavior, to, reset, scaleExtent, translateExtent, scaleTo};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue