-
Notifications
You must be signed in to change notification settings - Fork 881
Update math.getOffset algorithm to better align with spec #4119
Copy link
Copy link
Closed
Labels
prA pr has been created for the issueA pr has been created for the issuetech debtTechnical debt related tasksTechnical debt related tasks
Milestone
Description
As part of #4117 we determined that the math.getOffset calculation is not correct and needs to be updated. It didn't produce any false-positives so we decided to update the code in another pr in order to get 4.8 out the door.
The algorithm should be as follows:
For targets with target size >= 24x24px, we should make sure we skip the (potentially expensive) offset calculation since the spacing exception isn't relevant. Target size === largest unobscured rect from math.splitRects. E.g. the result of calling dom.getTargetSize.
Otherwise, for undersized targets:
- determine bounding rect of
targetand get the center (we'll callcenterTarget). Bounding rect === the result of callingmath.getBoundingRectfor each rect insplitRects. (should be a new function) - determine the target's "neighbors" using grid (any other target that might be within 24px of any part of
target's bounding rect is a neighbor) - for each
neighbor:- determine
neighborSplitRectsusingmath.splitRects(neighbor) - for each
neighborSplitRect:- calculate distance from
centerTargetto the nearest point inneighborSplitRect(may be 0 ifcenterTargetlies withinneighborSplitRect)
- calculate distance from
- let
neighborSpacingbe the minimumneighborSplitRectdistance - if the
neighboris also undersized (target size < 24x24px):- calculate
centerNeighborsimilarly tocenterTargetusing the neighbor's bounding box - if the distance from
centerTargettocenterNeighboris <neighborSpacing, use that as the newneighborSpacing
- calculate
- determine
- return the minimum
neighborSpacingfrom among all neighbors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prA pr has been created for the issueA pr has been created for the issuetech debtTechnical debt related tasksTechnical debt related tasks