Skip to content

Commit ccee9fe

Browse files
authored
Merge pull request #198 from cashapp/entin/sub-pixel-activation-point
Allow sub-pixel differences from default activation point
2 parents 371921a + ada8279 commit ccee9fe

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

Sources/AccessibilitySnapshot/Core/Swift/Classes/AccessibilityHierarchyParser.swift

+14-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ public final class AccessibilityHierarchyParser {
209209
userInputLabels: userInputLabels,
210210
shape: accessibilityShape(for: element.object, in: root),
211211
activationPoint: root.convert(activationPoint, from: nil),
212-
usesDefaultActivationPoint: (activationPoint == defaultActivationPoint(for: element.object)),
212+
usesDefaultActivationPoint: activationPoint.approximatelyEquals(
213+
defaultActivationPoint(for: element.object),
214+
tolerance: 1 / (root.window?.screen ?? UIScreen.main).scale
215+
),
213216
customActions: element.object.accessibilityCustomActions?.map { $0.name } ?? [],
214217
accessibilityLanguage: element.object.accessibilityLanguage
215218
)
@@ -702,3 +705,13 @@ extension UIView {
702705
}
703706

704707
}
708+
709+
// MARK: -
710+
711+
private extension CGPoint {
712+
713+
func approximatelyEquals(_ other: CGPoint, tolerance: CGFloat) -> Bool {
714+
return abs(self.x - other.x) < tolerance && abs(self.y - other.y) < tolerance
715+
}
716+
717+
}

0 commit comments

Comments
 (0)