Skip to content

Commit 1e6c267

Browse files
committed
Merge branch 'release/0.0.4'
2 parents d8598aa + 29e981e commit 1e6c267

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

ng2-img-map.ts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng2-img-map",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Responsive image mapping interface for Angular 2",
55
"main": "ng2-img-map.js",
66
"scripts": {

0 commit comments

Comments
 (0)