Fix poll option tracking unselecting options when location moves in between views

This commit is contained in:
Shadowfacts 2023-02-15 18:57:00 -05:00
parent 57fb921573
commit 6e5498430f
1 changed files with 6 additions and 1 deletions

View File

@ -121,9 +121,14 @@ class PollOptionsView: UIControl {
} }
override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
let location = touch.location(in: self)
var newIndex: Int? = nil var newIndex: Int? = nil
for (index, view) in options.enumerated() { for (index, view) in options.enumerated() {
if view.point(inside: touch.location(in: view), with: event) { var frame = view.frame
if index != options.count - 1 {
frame = frame.inset(by: UIEdgeInsets(top: 0, left: 0, bottom: -stack.spacing, right: 0))
}
if frame.contains(location) {
newIndex = index newIndex = index
break break
} }