(selector = 'img')
| 5 | * @returns {Promise} - Resolves when all specified images are loaded. |
| 6 | */ |
| 7 | const preloadImages = (selector = 'img') => { |
| 8 | return new Promise((resolve) => { |
| 9 | // The imagesLoaded library is used to ensure all images (including backgrounds) are fully loaded. |
| 10 | imagesLoaded(document.querySelectorAll(selector), {background: true}, resolve); |
| 11 | }); |
| 12 | }; |
| 13 | |
| 14 | /** |
| 15 | * Linear interpolation |