remove retry on resizeMarkers, as it caused move events to become mangled

This commit is contained in:
Iris Lightshard 2023-07-15 19:41:57 -06:00
parent e34ab4711c
commit d2c431760f
Signed by: nilix
GPG key ID: 3B7FBC22144E6398

View file

@ -24,11 +24,11 @@ function initializeMap(mapImgUrl) {
// this works but assumes the map is square (reasonable limitation I think) // this works but assumes the map is square (reasonable limitation I think)
function resizeMarkers() { function resizeMarkers() {
let tryAgain = false;
// for newly created tokens, the icon may not be loaded and thus the resize will not properly complete
// we need a way to queue the resize for when the icon is finished loading
tokens.forEach(t=>{ tokens.forEach(t=>{
if (t.m._icon == null) {
tryAgain = true;
} else {
const icon = t.m.options.icon; const icon = t.m.options.icon;
const scaleFactor = mapImg._image.clientWidth / mapImg._image.naturalWidth; const scaleFactor = mapImg._image.clientWidth / mapImg._image.naturalWidth;
@ -39,9 +39,7 @@ function resizeMarkers() {
t.m.setIcon(icon); t.m.setIcon(icon);
} }
}); });
if (tryAgain) {
setTimeout(resizeMarkers, 500)
}
} }
function processTokens(tokenChanges) { function processTokens(tokenChanges) {