diff --git a/Sources/ElegantColorPalette/Views/ColorPaletteScene.swift b/Sources/ElegantColorPalette/Views/ColorPaletteScene.swift index a4d621b..0a0e756 100644 --- a/Sources/ElegantColorPalette/Views/ColorPaletteScene.swift +++ b/Sources/ElegantColorPalette/Views/ColorPaletteScene.swift @@ -182,7 +182,10 @@ extension ColorPaletteScene { override func touchesMoved(_ touches: Set, 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, @@ -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) + } + +}