33 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44 */
55
6+ import { NgZone } from '@angular/core' ;
7+
68import { drag } from 'd3-drag' ;
79import { pointer , select } from 'd3-selection' ;
810import { ZoomBehavior , zoomIdentity , ZoomTransform } from 'd3-zoom' ;
911
12+ import { reqAnimFrame } from 'ng-zorro-antd/core/polyfill' ;
1013import { NzSafeAny } from 'ng-zorro-antd/core/types' ;
1114
1215import { NzZoomTransform } from '../interface' ;
@@ -28,6 +31,7 @@ export class Minimap {
2831 private unlisteners : VoidFunction [ ] = [ ] ;
2932
3033 constructor (
34+ private ngZone : NgZone ,
3135 private svg : SVGSVGElement ,
3236 private zoomG : SVGGElement ,
3337 private mainZoom : ZoomBehavior < NzSafeAny , NzSafeAny > ,
@@ -174,7 +178,7 @@ export class Minimap {
174178 if ( this . translate != null && this . zoom != null ) {
175179 // Update the viewpoint rectangle shape since the aspect ratio of the
176180 // map has changed.
177- requestAnimationFrame ( ( ) => this . zoom ( ) ) ;
181+ this . ngZone . runOutsideAngular ( ( ) => reqAnimFrame ( ( ) => this . zoom ( ) ) ) ;
178182 }
179183
180184 // Serialize the main svg to a string which will be used as the rendering
@@ -196,12 +200,15 @@ export class Minimap {
196200 context ! . clearRect ( 0 , 0 , this . canvasBuffer . width , this . canvasBuffer . height ) ;
197201
198202 context ! . drawImage ( image , minimapOffset . x , minimapOffset . y , this . minimapSize . width , this . minimapSize . height ) ;
199- requestAnimationFrame ( ( ) => {
200- // Hide the old canvas and show the new buffer canvas.
201- select ( this . canvasBuffer ) . style ( 'display' , 'block' ) ;
202- select ( this . canvas ) . style ( 'display' , 'none' ) ;
203- // Swap the two canvases.
204- [ this . canvas , this . canvasBuffer ] = [ this . canvasBuffer , this . canvas ] ;
203+
204+ this . ngZone . runOutsideAngular ( ( ) => {
205+ reqAnimFrame ( ( ) => {
206+ // Hide the old canvas and show the new buffer canvas.
207+ select ( this . canvasBuffer ) . style ( 'display' , 'block' ) ;
208+ select ( this . canvas ) . style ( 'display' , 'none' ) ;
209+ // Swap the two canvases.
210+ [ this . canvas , this . canvasBuffer ] = [ this . canvasBuffer , this . canvas ] ;
211+ } ) ;
205212 } ) ;
206213 } ;
207214
0 commit comments