MCPcopy Create free account
hub / github.com/codrops/GridItemHoverEffect / preloadImages

Function preloadImages

js/utils.js:6–13  ·  view source on GitHub ↗
(selector = 'img')

Source from the content-addressed store, hash-verified

4 * @returns {Promise} A promise that resolves when all the images are loaded.
5 */
6const preloadImages = (selector = 'img') => {
7 return new Promise((resolve) => {
8 // Use the imagesLoaded library to ensure all images are fully loaded.
9 // This is particularly useful for getting accurate dimensions, avoiding layout shifts, etc.
10 // `background: true` ensures background images are also loaded.
11 imagesLoaded(document.querySelectorAll(selector), {background: true}, resolve);
12 });
13};
14
15/**
16 * Determines the direction from which the mouse entered an element.

Callers 1

index.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected