From 8f7387f026c8b983f8896626c1db689e23e148b9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 27 May 2022 08:48:14 -0700 Subject: Preload map images once --- modern/src/map/core/preloadImages.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 modern/src/map/core/preloadImages.js (limited to 'modern/src/map/core/preloadImages.js') diff --git a/modern/src/map/core/preloadImages.js b/modern/src/map/core/preloadImages.js new file mode 100644 index 00000000..e0796e1f --- /dev/null +++ b/modern/src/map/core/preloadImages.js @@ -0,0 +1,19 @@ +import palette from '../../common/theme/palette'; +import deviceCategories from '../../common/util/deviceCategories'; +import { loadImage, prepareIcon } from './mapUtil'; + +export const mapImages = {}; + +export default async () => { + const background = await loadImage('images/background.svg'); + mapImages.background = await prepareIcon(background); + await Promise.all(deviceCategories.map(async (category) => { + const results = []; + ['positive', 'negative', 'neutral'].forEach((color) => { + results.push(loadImage(`images/icon/${category}.svg`).then((icon) => { + mapImages[`${category}-${color}`] = prepareIcon(background, icon, palette.colors[color]); + })); + }); + await Promise.all(results); + })); +}; -- cgit v1.2.3