From 485dc7e8c13f6a7760e5bf73604128e0226f8988 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 18 Sep 2018 02:12:35 +0900 Subject: [PATCH] zoom fixed 0.5x ~ 4x --- src/app/pages/home/home-page.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/pages/home/home-page.component.ts b/src/app/pages/home/home-page.component.ts index 6bf118c..5ad1111 100644 --- a/src/app/pages/home/home-page.component.ts +++ b/src/app/pages/home/home-page.component.ts @@ -199,10 +199,12 @@ export class HomePageComponent implements OnInit, OnDestroy { const svg = d3.select(this.discoveryTargetRef.nativeElement); - this.zoomBehavior = d3.zoom().on('zoom', () => { - const transform = d3.event.transform; - svg.select('g').attr('transform', 'translate(' + transform.x + ',' + transform.y + ') scale(' + transform.k + ')'); - }); + this.zoomBehavior = d3.zoom() + .scaleExtent([0.5, 4]) + .on('zoom', () => { + const transform = d3.event.transform; + svg.select('g').attr('transform', 'translate(' + transform.x + ',' + transform.y + ') scale(' + transform.k + ')'); + }); svg.call(this.zoomBehavior); const __this = this;