upddate animations

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-01 13:31:41 -05:00
parent 669c2b15b5
commit d7beea240c

View File

@ -328,22 +328,18 @@ import Combine
}
public override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touchesEnded")
knobReformAnimation()
// Action only occurs of the user lifts up from withing acceptable region of the toggle.
guard let coordinates = touches.first?.location(in: self),
coordinates.x > -20,
coordinates.x < bounds.width + 20,
coordinates.y > -20,
coordinates.y < bounds.height + 20
else { return }
let value = 20.0
guard let coordinates = touches.first?.location(in: self) else { return }
guard coordinates.x > -value else { return }
sendActions(for: .touchUpInside)
}
public func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) {
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touchesCancelled")
knobReformAnimation()
sendActions(for: .touchCancel)
}
@ -400,7 +396,7 @@ import Combine
self.knobView.backgroundColor = viewModel.on ? knobColor.on : knobColor.off
}, completion: nil)
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [], animations: {
constrainKnob()
}, completion: nil)
}