Asyncdisplaykit: [ASControlNode] TouchUpInside not being sent when touch ends inside hitTestSlop

Created on 9 Jan 2017  路  4Comments  路  Source: facebookarchive/AsyncDisplayKit

When using hitTestSlop to extend the hit area of an ASControlNode subclass, I've noticed that tapping outside the bounds (with a small tolerance) causes the node to highlight without triggering a TouchUpInside event.

The following code in ASControlNode seems to only take the original bounds + a hardcoded inset into account when determining whether to send the touch up inside event or not.

CGRect expandedBounds = CGRectInset(self.view.bounds, kASControlNodeExpandedInset, kASControlNodeExpandedInset);
  BOOL touchUpIsInsideExpandedBounds = CGRectContainsPoint(expandedBounds, touchLocation);

Is it possible that this should take the hitTestSlop into account, so that the final considered area is bounds + hitTestSlop + UIControlNode's expanded inset?

CGRectContainsPoint(UIEdgeInsetsInsetRect(expandedBounds, hitTestSlop), touchLocation)

ASControlNode Bug Needs Volunteer P3 Starter Task

Most helpful comment

Good catch! I believe the solution we want here, is to apply the hit test slop and _then_ apply kASControlNodeExpandedInset to get the bounds in this case.

All 4 comments

Good catch! I believe the solution we want here, is to apply the hit test slop and _then_ apply kASControlNodeExpandedInset to get the bounds in this case.

@GitGadd - would you be willing to implement this for us?

@hannahmbanana Definitely! I've been thinking about contributing, and this seems like an easy start.

Was this page helpful?
0 / 5 - 0 ratings