(element, lastX, lastY)
| 21 | * @returns {string} - A string indicating the direction ("top", "right", "bottom", "left", or "unknown"). |
| 22 | */ |
| 23 | const 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 | |
| 34 | export { |
| 35 | preloadImages, |