1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-11 05:05:23 +03:00

Review improvements

This commit is contained in:
Alisa Mylnikova 2019-06-07 13:48:15 +07:00
parent 8b2027af27
commit 65f008e5df
3 changed files with 19 additions and 8 deletions

View File

@ -184,7 +184,6 @@ extension AnimationProducer {
CATransaction.setDisableActions(true)
defer {
CATransaction.commit()
//CATransaction.flush()
}
// Launching

View File

@ -37,7 +37,7 @@ public struct TouchPoint {
private let absoluteLocation: Point
private let relativeLocation: Point // location inside the node
private let viewLocation: Point // location relative t
private let viewLocation: Point // location relative to containing view - no content layout or zoom transformations
init(id: Int, location: Point, relativeToNodeLocation: Point, relativeToViewLocation: Point) {
self.id = id

View File

@ -252,8 +252,10 @@ open class MacawView: MView, MGestureRecognizerDelegate {
let inverted = node.place.invert()!
let loc = location.applying(inverted.toCG())
let invertedViewPlace = self.place.invert()!
let relativeToView = location.applying(invertedViewPlace.toCG())
var relativeToView = CGPoint.zero
if let invertedViewPlace = self.place.invert() {
relativeToView = location.applying(invertedViewPlace.toCG())
}
let id = Int(bitPattern: Unmanaged.passUnretained(touch).toOpaque())
@ -292,7 +294,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
return
}
let invertedViewPlace = self.place.invert()!
let invertedViewPlace = self.place.invert()
var points = [TouchPoint]()
for initialTouch in initialTouches {
guard let currentIndex = touchPoints.firstIndex(of: initialTouch) else {
@ -305,7 +307,12 @@ open class MacawView: MView, MGestureRecognizerDelegate {
let location = CGPoint(x: currentTouch.x, y: currentTouch.y)
let inverted = currentNode.place.invert()!
let loc = location.applying(inverted.toCG())
let relativeToView = location.applying(invertedViewPlace.toCG())
var relativeToView = CGPoint.zero
if let invertedViewPlace = invertedViewPlace {
relativeToView = location.applying(invertedViewPlace.toCG())
}
let point = TouchPoint(id: currentTouch.id, location: loc.toMacaw(), relativeToNodeLocation: nodePath.location.toMacaw(), relativeToViewLocation: relativeToView.toMacaw())
points.append(point)
}
@ -337,7 +344,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
return
}
let invertedViewPlace = self.place.invert()!
let invertedViewPlace = self.place.invert()
let touchPoints = convert(touches: touches)
for touch in touchPoints {
@ -347,7 +354,12 @@ open class MacawView: MView, MGestureRecognizerDelegate {
let inverted = node.place.invert()!
let location = CGPoint(x: touch.x, y: touch.y)
let loc = location.applying(inverted.toCG())
let relativeToView = location.applying(invertedViewPlace.toCG())
var relativeToView = CGPoint.zero
if let invertedViewPlace = invertedViewPlace {
relativeToView = location.applying(invertedViewPlace.toCG())
}
let id = Int(bitPattern: Unmanaged.passUnretained(touch).toOpaque())
let point = TouchPoint(id: id, location: loc.toMacaw(), relativeToNodeLocation: nodePath.location.toMacaw(), relativeToViewLocation: relativeToView.toMacaw())
let touchEvent = TouchEvent(node: node, points: [point])