From d7beea240c0d49f8ed53243f42334b5eb7ad551c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 1 Aug 2022 13:31:41 -0500 Subject: [PATCH] upddate animations Signed-off-by: Matt Bruce --- VDS/Components/Toggle/VDSToggle.swift | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/VDS/Components/Toggle/VDSToggle.swift b/VDS/Components/Toggle/VDSToggle.swift index 81c3defb..d23ddea4 100644 --- a/VDS/Components/Toggle/VDSToggle.swift +++ b/VDS/Components/Toggle/VDSToggle.swift @@ -328,22 +328,18 @@ import Combine } public override func touchesEnded(_ touches: Set, 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, with event: UIEvent) { - + open override func touchesCancelled(_ touches: Set, 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) }