Skip to content

Commit e4b41fa

Browse files
committed
Fix cursor follower hover handoff when moving from badge to link
Badges are nested inside links, so mouseenter on the link fires once on entry and never re-fires when the cursor moves from a badge back to the link text. Added an isOverInteractive flag tracked by mouseenter/mouseleave to re-apply the hovering class when leaving badge proximity while still over a link.
1 parent 2e2dee0 commit e4b41fa

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

index.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,8 +2691,14 @@
26912691
cursorFollower.style.top = followerY + 'px';
26922692

26932693
// Track proximity separately from visual morph
2694+
var wasBadge = !!activeBadge;
26942695
activeBadge = closestEl || null;
26952696

2697+
// Re-apply hover when leaving badge but still over a link
2698+
if (wasBadge && !activeBadge && isOverInteractive) {
2699+
cursorFollower.classList.add('hovering');
2700+
}
2701+
26962702
// Shape: only apply transform/borderRadius when morphing
26972703
var isBlob = Math.abs(currentScaleX - 1) > 0.01 || Math.abs(currentScaleY - 1) > 0.01;
26982704

@@ -2702,8 +2708,8 @@
27022708
cursorFollower.style.transform =
27032709
'translate(-50%, -50%) scale(' + currentScaleX.toFixed(3) + ',' + currentScaleY.toFixed(3) + ')';
27042710
cursorFollower.style.borderRadius = currentBorderRadius.toFixed(1) + 'px';
2705-
} else if (isBlob && !closestRect && cursorFollower.classList.contains('hovering')) {
2706-
// Left badge, now on a link: snap morph to default so CSS hover works
2711+
} else if (isBlob && cursorFollower.classList.contains('hovering')) {
2712+
// Left badge, on a link: snap morph to default so CSS hover works
27072713
currentScaleX = 1;
27082714
currentScaleY = 1;
27092715
currentBorderRadius = 6;
@@ -2729,12 +2735,15 @@
27292735
animateFollower();
27302736

27312737
// Link hover — original behaviour (CSS width/height transition)
2738+
var isOverInteractive = false;
27322739
var interactiveElements = document.querySelectorAll('a, button, .theme-toggle');
27332740
interactiveElements.forEach(function(el) {
27342741
el.addEventListener('mouseenter', function() {
2742+
isOverInteractive = true;
27352743
if (!activeBadge) cursorFollower.classList.add('hovering');
27362744
});
27372745
el.addEventListener('mouseleave', function() {
2746+
isOverInteractive = false;
27382747
cursorFollower.classList.remove('hovering');
27392748
});
27402749
});

0 commit comments

Comments
 (0)