(staticContainer, dynamicContainer, mapWidth, mapHeight, mode)
| 278 | } |
| 279 | |
| 280 | export function initMap(staticContainer, dynamicContainer, mapWidth, mapHeight, mode) { |
| 281 | if (animationId !== null) { |
| 282 | cancelAnimationFrame(animationId); |
| 283 | } |
| 284 | canvas = dynamicContainer; |
| 285 | width = mapWidth; |
| 286 | height = mapHeight; |
| 287 | proportion = width / 1700; |
| 288 | initCanvas(staticContainer); |
| 289 | initCanvas(dynamicContainer); |
| 290 | ctx = canvas.getContext("2d"); |
| 291 | drawMap(staticContainer, mode); |
| 292 | redraw(mode); |
| 293 | |
| 294 | return () => { |
| 295 | if (canvas === dynamicContainer) { |
| 296 | cancelAnimationFrame(animationId); |
| 297 | clearTimeout(forceTimeoutId); |
| 298 | animationId = null; |
| 299 | forceTimeoutId = null; |
| 300 | force = false; |
| 301 | canvas = null; |
| 302 | ctx = null; |
| 303 | } |
| 304 | }; |
| 305 | } |
| 306 | |
| 307 | export function clickHandler(e) { |
| 308 | const {left, top} = e.currentTarget.getBoundingClientRect(); |
no test coverage detected