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

Function getMouseEnterDirection

js/utils.js:23–32  ·  view source on GitHub ↗
(element, lastX, lastY)

Source from the content-addressed store, hash-verified

21 * @returns {string} - A string indicating the direction ("top", "right", "bottom", "left", or "unknown").
22 */
23const getMouseEnterDirection = (element, lastX, lastY) => {
24 const { top, right, bottom, left } = element.getBoundingClientRect();
25
26 if (lastY <= Math.floor(top)) return "top";
27 if (lastY >= Math.floor(bottom)) return "bottom";
28 if (lastX <= Math.floor(left)) return "left";
29 if (lastX >= Math.floor(right)) return "right";
30
31 return "unknown";
32}
33
34export {
35 preloadImages,

Callers 1

enterMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected