diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 2131df8c..13f50e7f 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -43,7 +43,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab var isHighlightAnimating = false open override var isHighlighted: Bool { didSet { - if isHighlightAnimating == false && isClickable { + if isHighlightAnimating == false && touchUpInsideCount > 0 { isHighlightAnimating = true UIView.animate(withDuration: 0.1, animations: { [weak self] in self?.updateView() diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 322f1250..41633216 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -64,7 +64,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab open override var isHighlighted: Bool { didSet { - if isHighlightAnimating == false && isClickable { + if isHighlightAnimating == false && touchUpInsideCount > 0 { isHighlightAnimating = true UIView.animate(withDuration: 0.1, animations: { [weak self] in self?.updateView() diff --git a/VDS/Protocols/Clickable.swift b/VDS/Protocols/Clickable.swift index 1bf454f6..4ffecf2b 100644 --- a/VDS/Protocols/Clickable.swift +++ b/VDS/Protocols/Clickable.swift @@ -9,23 +9,19 @@ import Foundation import UIKit import Combine -public protocol Clickable where Self: UIControl { +public protocol Clickable: Handlerable where Self: UIControl { var touchUpInsideCount: Int { get set } var onClickSubscriber: AnyCancellable? { get set } } -extension Clickable where Self: Handlerable { +extension Clickable { public func addEvent(event: UIControl.Event, block: @escaping (Self)->()) { publisher(for: event) .sink(receiveValue: { c in block(c) }).store(in: &subscribers) } - - internal var isClickable: Bool { return touchUpInsideCount > 0 } -} -extension Clickable { public var onClick: ((Self) -> ())? { get { return nil } set {