@@ -152,35 +152,37 @@ export class ImgMapComponent {
152152 * Clears the canvas and draws the markers.
153153 */
154154 private draw ( ) {
155- const canvas : HTMLCanvasElement = this . canvas . nativeElement ;
156- const container : HTMLDivElement = this . container . nativeElement ;
157- const image : HTMLImageElement = this . image . nativeElement ;
158- const height = image . clientHeight ;
159- const width = image . clientWidth ;
160- this . renderer . setElementAttribute ( canvas , 'height' , `${ height } ` ) ;
161- this . renderer . setElementAttribute ( canvas , 'width' , `${ width } ` ) ;
162- this . renderer . setElementStyle ( container , 'height' , `${ height } px` ) ;
163- const context = canvas . getContext ( '2d' ) ;
164- context . clearRect ( 0 , 0 , width , height ) ;
165- this . pixels = [ ] ;
166- this . markers . forEach ( marker => {
167- this . pixels . push ( this . markerToPixel ( marker ) ) ;
168- } ) ;
169- if ( this . marker ) {
170- this . pixel = this . markerToPixel ( this . marker ) ;
171- }
172- this . pixels . forEach ( ( pixel , index ) => {
173- if ( this . markerActive === index ) {
174- this . drawMarker ( pixel , 'active' ) ;
175- } else if ( this . markerHover === index ) {
176- this . drawMarker ( pixel , 'hover' ) ;
177- } else {
178- this . drawMarker ( pixel ) ;
155+ window . setTimeout ( ( ) => {
156+ const canvas : HTMLCanvasElement = this . canvas . nativeElement ;
157+ const container : HTMLDivElement = this . container . nativeElement ;
158+ const image : HTMLImageElement = this . image . nativeElement ;
159+ const height = image . clientHeight ;
160+ const width = image . clientWidth ;
161+ this . renderer . setElementAttribute ( canvas , 'height' , `${ height } ` ) ;
162+ this . renderer . setElementAttribute ( canvas , 'width' , `${ width } ` ) ;
163+ this . renderer . setElementStyle ( container , 'height' , `${ height } px` ) ;
164+ const context = canvas . getContext ( '2d' ) ;
165+ context . clearRect ( 0 , 0 , width , height ) ;
166+ this . pixels = [ ] ;
167+ this . markers . forEach ( marker => {
168+ this . pixels . push ( this . markerToPixel ( marker ) ) ;
169+ } ) ;
170+ if ( this . marker ) {
171+ this . pixel = this . markerToPixel ( this . marker ) ;
179172 }
180- } ) ;
181- if ( this . pixel ) {
182- this . drawMarker ( this . pixel , 'active' ) ;
183- }
173+ this . pixels . forEach ( ( pixel , index ) => {
174+ if ( this . markerActive === index ) {
175+ this . drawMarker ( pixel , 'active' ) ;
176+ } else if ( this . markerHover === index ) {
177+ this . drawMarker ( pixel , 'hover' ) ;
178+ } else {
179+ this . drawMarker ( pixel ) ;
180+ }
181+ } ) ;
182+ if ( this . pixel ) {
183+ this . drawMarker ( this . pixel , 'active' ) ;
184+ }
185+ } , 1 ) ;
184186 }
185187
186188 /**
0 commit comments