Skip to content

Commit

Permalink
Merge pull request #198 from cashapp/entin/sub-pixel-activation-point
Browse files Browse the repository at this point in the history
Allow sub-pixel differences from default activation point
  • Loading branch information
NickEntin authored Jan 27, 2024
2 parents 371921a + ada8279 commit ccee9fe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ public final class AccessibilityHierarchyParser {
userInputLabels: userInputLabels,
shape: accessibilityShape(for: element.object, in: root),
activationPoint: root.convert(activationPoint, from: nil),
usesDefaultActivationPoint: (activationPoint == defaultActivationPoint(for: element.object)),
usesDefaultActivationPoint: activationPoint.approximatelyEquals(
defaultActivationPoint(for: element.object),
tolerance: 1 / (root.window?.screen ?? UIScreen.main).scale
),
customActions: element.object.accessibilityCustomActions?.map { $0.name } ?? [],
accessibilityLanguage: element.object.accessibilityLanguage
)
Expand Down Expand Up @@ -702,3 +705,13 @@ extension UIView {
}

}

// MARK: -

private extension CGPoint {

func approximatelyEquals(_ other: CGPoint, tolerance: CGFloat) -> Bool {
return abs(self.x - other.x) < tolerance && abs(self.y - other.y) < tolerance
}

}

0 comments on commit ccee9fe

Please sign in to comment.