File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-img-mapper" ,
3
- "version" : " 1.3 .0" ,
3
+ "version" : " 1.4 .0" ,
4
4
"description" : " React Component to highlight interactive zones in images" ,
5
5
"keywords" : [
6
6
" react" ,
Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ const ImageMapper: React.FC<ImageMapperProps> = (props: ImageMapperProps) => {
52
52
const ctx = useRef < CanvasRenderingContext2D > ( null ) ;
53
53
const isInitialMount = useRef < boolean > ( true ) ;
54
54
55
+ useEffect ( ( ) => {
56
+ initCanvas ( true ) ;
57
+ ctx . current = canvas . current . getContext ( '2d' ) ;
58
+ updateCacheMap ( ) ;
59
+ setRendered ( true ) ;
60
+ } , [ ] ) ;
61
+
55
62
useEffect ( ( ) => {
56
63
if ( isInitialMount . current ) {
57
64
isInitialMount . current = false ;
@@ -62,12 +69,6 @@ const ImageMapper: React.FC<ImageMapperProps> = (props: ImageMapperProps) => {
62
69
}
63
70
} , [ props , isInitialMount , imgRef ] ) ;
64
71
65
- useEffect ( ( ) => {
66
- ctx . current = canvas . current . getContext ( '2d' ) ;
67
- updateCacheMap ( ) ;
68
- setRendered ( true ) ;
69
- } , [ ] ) ;
70
-
71
72
useEffect ( ( ) => {
72
73
container . current . clearHighlightedArea = ( ) => {
73
74
setMap ( storedMap ) ;
@@ -293,7 +294,6 @@ const ImageMapper: React.FC<ImageMapperProps> = (props: ImageMapperProps) => {
293
294
useMap = { `#${ map . name } ` }
294
295
alt = "map"
295
296
ref = { img }
296
- onLoad = { ( ) => initCanvas ( true ) }
297
297
onClick = { event => imageClick ( event , props ) }
298
298
onMouseMove = { event => imageMouseMove ( event , props ) }
299
299
/>
You can’t perform that action at this time.
0 commit comments