Skip to content

Commit

Permalink
fixed bug on older iphones like 8 and below where a tap would be regi…
Browse files Browse the repository at this point in the history
…stered as a drag
  • Loading branch information
ThasianX committed Aug 2, 2020
1 parent 76a6784 commit e4ae44e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Sources/ElegantColorPalette/Views/ColorPaletteScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ extension ColorPaletteScene {

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let activeNode = state.activeNode else { return }
guard let location = touches.first?.location(in: self) else { return }
guard let touch = touches.first else { return }
let location = touch.location(in: self)
let previous = touch.previousLocation(in: self)
guard location.distance(from: previous) != 0 else { return }
guard isTouchWithinFrame(location) else { return }

let offset = CGPoint(x: location.x - activeNode.position.x,
Expand Down Expand Up @@ -282,3 +285,12 @@ private extension ColorPaletteScene {
}

}

// MARK: - Extensions
private extension CGPoint {

func distance(from point: CGPoint) -> CGFloat {
return hypot(point.x - x, point.y - y)
}

}

0 comments on commit e4ae44e

Please sign in to comment.