bjornd / jvectormap

jvectormap.com
GNU Affero General Public License v3.0
1.39k stars 430 forks source link

Resize issue #444

Open dorianrod opened 6 years ago

dorianrod commented 6 years ago

Hi, I encountered an issue when I resize the map. The map container size is programatically resized, then i use the "updateSize" function. If I resize slowly, the size of the map is ok, but if I shrink quickly the window then the map slowly shrinks and then stop shriking, so the map overflows the container.

I don't know the cause, but i wrote a workaround if someone encounters the same issue. Not really beautiful, but it works :). The idea is to call X times the updateSize function, and stop as soon as the size of the map is not updated by the function.

` //this.map is the jvectormap object let lastWidth = null; let resize = (i)=> { console.log("resize iteration", i); console.log("lastWidth", lastWidth, this.map.width); this.map.updateSize(); setTimeout(()=>{ if( Math.abs(this.map.width - lastWidth) > 2) { lastWidth = this.map.width; resize(i+1); } },5); } resize(0);

`

Have a good day !

Dorian

katalin2003 commented 3 years ago

Hello @dorianrod. I have the same issue. While I don't really know yet how to implement your fix, I just wanted to say thanks for posting it!