Skip to content

Commit

Permalink
fix hovered state of group listeners
Browse files Browse the repository at this point in the history
fixes #7838

Diffs=
4fb978a92 fix hovered state of group listeners (#7839)
e75b8fa63 Update version to macosx 11 for runtime. (#7829)
55de8286c feat: add nested text run getters and setters in Unity (#7808)

Co-authored-by: hernan <[email protected]>
  • Loading branch information
bodymovin and bodymovin committed Aug 14, 2024
1 parent 94ef390 commit 76b5584
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
89f9b3bd5e1f3715c9db996e0708fc4da10fe180
4fb978a9230fc006b5e575364f062907e7dd2afe
15 changes: 15 additions & 0 deletions lib/src/rive_core/state_machine_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,10 @@ class _ListenerGroup {
_isHovered = true;
}

void unhover() {
_isHovered = false;
}

void reset() {
_isConsumed = false;
_prevIsHovered = _isHovered;
Expand Down Expand Up @@ -902,6 +906,17 @@ class _HitShape extends _HitComponent {
if (listenerGroup.isConsumed()) {
continue;
}
// Because each group is tested individually for its hover state, a group
// could be marked "incorrectly" as hovered at this point.
// But once we iterate each element in the drawing order, that group can
// be occluded by an opaque target on top of it.
// So although it is hovered in isolation, it shouldn't be considered as
// hovered in the full context.
// In this case, we unhover the group so it is not marked as previously
// hovered.
if (!canHit && listenerGroup.isHovered()) {
listenerGroup.unhover();
}
final isGroupHovered = canHit && listenerGroup.isHovered();
bool hoverChange = listenerGroup.prevHovered() != isGroupHovered;
// If hover has changes, it means that the element is hovered for the
Expand Down

0 comments on commit 76b5584

Please sign in to comment.