| 189 | window.addEventListener('mouseup', mouseUpHandler); |
| 190 | |
| 191 | const enterHandler = e => { |
| 192 | const directTarget = e.target; |
| 193 | const allTargets = []; |
| 194 | let current = directTarget; |
| 195 | while (current && current !== document.body) { |
| 196 | if (current.matches(targetSelector)) { |
| 197 | allTargets.push(current); |
| 198 | } |
| 199 | current = current.parentElement; |
| 200 | } |
| 201 | const target = allTargets[0] || null; |
| 202 | if (!target || !cursorRef.current || !cornersRef.current) return; |
| 203 | if (activeTarget === target) return; |
| 204 | if (activeTarget) { |
| 205 | cleanupTarget(activeTarget); |
| 206 | } |
| 207 | if (resumeTimeout) { |
| 208 | clearTimeout(resumeTimeout); |
| 209 | resumeTimeout = null; |
| 210 | } |
| 211 | |
| 212 | activeTarget = target; |
| 213 | const corners = Array.from(cornersRef.current); |
| 214 | corners.forEach(corner => gsap.killTweensOf(corner, 'x,y')); |
| 215 | gsap.killTweensOf(cursorRef.current, 'rotation'); |
| 216 | spinTl.current?.pause(); |
| 217 | gsap.set(cursorRef.current, { rotation: 0 }); |
| 218 | |
| 219 | if (cursorColorOnTarget) { |
| 220 | gsap.to(corners, { |
| 221 | borderColor: cursorColorOnTarget, |
| 222 | duration: 0.15, |
| 223 | ease: 'power2.out' |
| 224 | }); |
| 225 | if (dotRef.current) { |
| 226 | gsap.to(dotRef.current, { |
| 227 | backgroundColor: cursorColorOnTarget, |
| 228 | duration: 0.15, |
| 229 | ease: 'power2.out' |
| 230 | }); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | const rect = target.getBoundingClientRect(); |
| 235 | const { borderWidth, cornerSize } = constants; |
| 236 | const { x: offsetX, y: offsetY } = getOffset(); |
| 237 | const cursorX = gsap.getProperty(cursorRef.current, 'x'); |
| 238 | const cursorY = gsap.getProperty(cursorRef.current, 'y'); |
| 239 | |
| 240 | targetCornerPositionsRef.current = [ |
| 241 | { x: rect.left - borderWidth - offsetX, y: rect.top - borderWidth - offsetY }, |
| 242 | { x: rect.right + borderWidth - cornerSize - offsetX, y: rect.top - borderWidth - offsetY }, |
| 243 | { x: rect.right + borderWidth - cornerSize - offsetX, y: rect.bottom + borderWidth - cornerSize - offsetY }, |
| 244 | { x: rect.left - borderWidth - offsetX, y: rect.bottom + borderWidth - cornerSize - offsetY } |
| 245 | ]; |
| 246 | |
| 247 | isActiveRef.current = true; |
| 248 | gsap.ticker.add(tickerFnRef.current); |
nothing calls this directly
no test coverage detected