From 5c4f8fd46454d421280176cfc9a929938cf6c32d Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 5 Nov 2024 23:51:45 +0100 Subject: [PATCH] debug interactive map on stage --- .../erable_mod/assets/js/carte-interactive.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/web/modules/custom/erable_mod/assets/js/carte-interactive.js b/web/modules/custom/erable_mod/assets/js/carte-interactive.js index 0775307..a7aa743 100644 --- a/web/modules/custom/erable_mod/assets/js/carte-interactive.js +++ b/web/modules/custom/erable_mod/assets/js/carte-interactive.js @@ -172,8 +172,7 @@ for (let icon of projectsIcons) { }); } -function placeProjectsIcons(projectsIcons) { - const container = document.querySelector('#map_base'); +function placeProjectsIcons(projectsIcons, container) { const containerWidth = container.getBoundingClientRect().width; const containerHeight = container.getBoundingClientRect().height; @@ -261,10 +260,16 @@ function hidePopup(){ // debugMapPlacement(); document.addEventListener('DOMContentLoaded', () => { - placeProjectsIcons(projectsIcons); - window.addEventListener('resize', () => { - placeProjectsIcons(projectsIcons) - }); + let containerImg = document.querySelector('#map_base'); + containerImg.addEventListener('load', () => { + placeProjectsIcons(projectsIcons, containerImg); + window.addEventListener('resize', () => { + placeProjectsIcons(projectsIcons, containerImg); + }); + }) + if (containerImg.complete) { + placeProjectsIcons(projectsIcons, containerImg); + } }); function debugMapPlacement() {