Commit 54ff8dbe by Dmitriy Stepanets

Added gesture recognizer to timeline

parent 7718da56
...@@ -165,12 +165,21 @@ class MapTimeControlView: UIView { ...@@ -165,12 +165,21 @@ class MapTimeControlView: UIView {
self.playButtonState = .play self.playButtonState = .play
} }
} }
@objc private func handleTapGesture(gestureRecoginzer:UIGestureRecognizer) {
let location = gestureRecoginzer.location(in: self)
let progress = max(location.x - stackView.frame.origin.x, 0) / (self.bounds.width - stackView.frame.origin.x)
let targetIndex = Int(CGFloat(currentItems.count) * progress)
let selectedItem = currentItems[max(targetIndex, currentItems.count - 1)]
}
} }
//MARK:- Prepare //MARK:- Prepare
private extension MapTimeControlView { private extension MapTimeControlView {
func prepareView() { func prepareView() {
backgroundColor = .clear backgroundColor = .clear
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(gestureRecoginzer:)))
addGestureRecognizer(tapGesture)
} }
func prepareContainer() { func prepareContainer() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment