Skip to content

Commit

Permalink
feat #95: 그래프 확대/축소 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
enebin committed Sep 8, 2023
1 parent 75a5e18 commit dcc5371
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import UIKit
class PinchZoomView: UIView {
weak var delegate: PinchZoomViewDelgate?

private var lastScale: CGFloat = 1

private(set) var scale: CGFloat = 0 {
didSet {
delegate?.pinchZoomView(self, didChangeScale: scale)
Expand Down Expand Up @@ -74,14 +76,15 @@ class PinchZoomView: UIView {
numberOfTouches = gesture.numberOfTouches
}

scale = gesture.scale
scale = lastScale * gesture.scale

location = gesture.location(in: self)
offset = CGSize(width: location.x - startLocation.x, height: location.y - startLocation.y)

case .ended, .cancelled, .failed:
isPinching = false
scale = 1.0
scale = scale.between(min: 0.5, max: 2.0)
lastScale = scale
anchor = .center
offset = .zero
default:
Expand Down

0 comments on commit dcc5371

Please sign in to comment.