diff --git a/plugins/minimap/index.js b/plugins/minimap/index.js index d5c4dd117b..07ee1df116 100644 --- a/plugins/minimap/index.js +++ b/plugins/minimap/index.js @@ -76,9 +76,6 @@ class Minimap extends Base { const cfgs = this._cfgs; const size = cfgs.size; const graph = cfgs.graph; - const pixelRatio = graph.get('pixelRatio') || graph.get('canvas').get('pixelRatio'); - const widthRatio = graph.get('width') / size[0] * pixelRatio; - const heightRatio = graph.get('height') / size[1] * pixelRatio; const canvas = this.get('canvas'); const containerDOM = canvas.get('containerDOM'); const viewport = createDOM('
'); @@ -90,6 +87,7 @@ class Minimap extends Base { width, // 缓存viewport当前宽度 height; // 缓存viewport当前高度 containerDOM.addEventListener('mousedown', e => { + cfgs.refresh = false; if (e.target !== viewport) { return; } @@ -131,15 +129,18 @@ class Minimap extends Base { left: left + 'px', top: top + 'px' }); - graph.translate(dx * widthRatio * pixelRatio, dy * heightRatio * pixelRatio); + const ratio = this.get('ratio'); + graph.translate(dx / ratio, dy / ratio); x = e.clientX; y = e.clientY; }, false); containerDOM.addEventListener('mouseleave', () => { dragging = false; + cfgs.refresh = true; }, false); containerDOM.addEventListener('mouseup', () => { dragging = false; + cfgs.refresh = true; }, false); this.set('viewport', viewport); containerDOM.appendChild(viewport); @@ -270,7 +271,7 @@ class Minimap extends Base { if (height > size[1]) { height = size[1]; } - + this.set('ratio', ratio); modifyCSS(viewport, { left: left > 0 ? left + 'px' : 0, top: top > 0 ? top + 'px' : 0,