Skip to content

Commit

Permalink
Swap recognizer.locationInView() for CGRectContainsPoint()
Browse files Browse the repository at this point in the history
  • Loading branch information
crenwick committed Mar 29, 2016
1 parent bb81a9f commit e5babcd
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions STP/Tappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ public extension Tappable where Self:UIView {
let tap = recognizer as! UILongPressGestureRecognizer

func isInFrame() -> Bool {
let location = recognizer.locationInView(self)
switch location {
case _ where location.x < 0 - self.frame.size.width / 2,
_ where location.x > self.frame.size.width * 1.5,
_ where location.y < 0 - self.frame.size.height / 2,
_ where location.y > self.frame.size.height * 1.5:
return false
default:
return true
}
return CGRectContainsPoint(
CGRectInset(self.frame, self.frame.width * -0.5, self.frame.height * -0.5),
recognizer.locationInView(self)
)
}

switch tap.state {
Expand Down

0 comments on commit e5babcd

Please sign in to comment.