img-mapper/react-img-mapper

Map freezing/stuck random, coords Infinity

Closed this issue · 10 comments

Describe the bug
It doesnt happend on Firefox.
The problem is when you move the mouse cursor over the image map, sometimes it stills freeze, stuck.
Checking the code, it makes a math division,
return coords.map(function (coord) { return coord / (imgRef.naturalWidth / parentWidth); });
and debugging it, sometimes 'imgRef.naturalWidth ' is zero (0)

Error Stack
npm package version v1.3.0

You could see "infinity" coords on each element of map:
<area shape="poly" coords="Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity,Infinity" href="#" alt="map">

Expected behavior
Don't do that :)

Screenshots
image

Desktop (please complete the following information):

  • OS: Linux, Windows, MacOs
  • Browser: latest safari/chrome
  • Version: Chrome 105

We have a fix

File:
dist/ImageMapper.js

Change:
if (responsive && parentWidth) {

by

if (responsive && parentWidth && imgRef.naturalWidth) {

Did you check with version V1.3.0?

Did you check with version V1.3.0?

yes, i used that version v1.3.0
and this version is not on this repository as a tag or release, only in npm

Yes, it is not listed but you can directly download it from npm.

Yeah, and it has a fail, that i fixed as commented in this issue

Hi guys, can the fix be uploaded or PR merged? I have the same problem, sometimes/random the map doesn't work and show cords as infinity.

Thanks!

Same problem :(

Guys, I apologize for the lack of updates lately, but I will make sure to get them fixed by this weekend.

anyone fixed this problem?

Duplicate of #42