diff --git a/Tusker/Screens/Gallery/VideoControlsViewController.swift b/Tusker/Screens/Gallery/VideoControlsViewController.swift index 94d163e3..7b2160d5 100644 --- a/Tusker/Screens/Gallery/VideoControlsViewController.swift +++ b/Tusker/Screens/Gallery/VideoControlsViewController.swift @@ -270,8 +270,13 @@ private class VideoScrubbingControl: UIControl { } override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { - touchStartLocation = touch.location(in: self) - scrubbingStartFraction = fractionComplete + if touch.type == .pencil || touch.type == .indirectPointer { + touchStartLocation = .zero + scrubbingStartFraction = 0 + } else { + touchStartLocation = touch.location(in: self) + scrubbingStartFraction = fractionComplete + } animator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) animator!.addAnimations { @@ -290,13 +295,20 @@ private class VideoScrubbingControl: UIControl { feedbackGenerator!.prepare() #endif + updateScrubbing(for: touch) + return true } override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { + updateScrubbing(for: touch) + return true + } + + private func updateScrubbing(for touch: UITouch) { guard let touchStartLocation, let scrubbingStartFraction else { - return false + return } let location = touch.location(in: self) let translation = CGPoint(x: location.x - touchStartLocation.x, y: location.y - touchStartLocation.y) @@ -326,8 +338,6 @@ private class VideoScrubbingControl: UIControl { transform = CGAffineTransform(scaleX: 1 + stretchAmount / bounds.width, y: 1 + 0.5 * (1 - stretchFactor)) .translatedBy(x: sign(unclampedFractionComplete) * stretchAmount / 2, y: 0) } - - return true } override func endTracking(_ touch: UITouch?, with event: UIEvent?) {