diff --git a/VDS/BaseClasses/Control.swift b/VDS/BaseClasses/Control.swift index a8b62ed1..ce90d271 100644 --- a/VDS/BaseClasses/Control.swift +++ b/VDS/BaseClasses/Control.swift @@ -71,10 +71,8 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable { didSet { if shouldHighlight { isHighlighting = true - UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.setNeedsUpdate() - self?.isHighlighting = false - }) + setNeedsUpdate() + isHighlighting = false } } } diff --git a/VDS/Components/Buttons/ButtonBase.swift b/VDS/Components/Buttons/ButtonBase.swift index 83627736..64dbea7e 100644 --- a/VDS/Components/Buttons/ButtonBase.swift +++ b/VDS/Components/Buttons/ButtonBase.swift @@ -77,26 +77,23 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { open var userInfo = [String: Primitive]() - internal var isHighlightAnimating = false + /// State of animating isHighlight. + public var isHighlighting = false + + /// Whether the Button should handle the isHighlighted state. + open var shouldHighlight: Bool { isHighlighting == false && onClickSubscriber != nil } /// Whether the Control is highlighted or not. open override var isHighlighted: Bool { didSet { - if isHighlightAnimating == false && onClickSubscriber != nil { - isHighlightAnimating = true - UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.setNeedsUpdate() - }) { [weak self] _ in - //you update the view since this is typically a quick change - UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.setNeedsUpdate() - self?.isHighlightAnimating = false - }) - } + if shouldHighlight { + isHighlighting = true + setNeedsUpdate() + isHighlighting = false } } } - + /// Whether the Control is enabled or not. open override var isEnabled: Bool { didSet { setNeedsUpdate() } }