Skip to content

Commit

Permalink
Merge pull request #174 from NausJ/tapHandlerOnOriginatingFrame
Browse files Browse the repository at this point in the history
When the originating frame is tapped, call the tapHandler.
  • Loading branch information
andreamazz authored Mar 28, 2019
2 parents 52a6fe1 + 2a9ed87 commit 747c5ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/PopTip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ open class PopTip: UIView {
@objc open dynamic var shouldDismissOnTap = true
/// A boolean value that determines whether to dismiss when tapping outside the poptip.
@objc open dynamic var shouldDismissOnTapOutside = true
/// A boolean value that determines whether to consider the originating frame as part of the poptip,
/// i.e wether to call the `tapHandler` or the `tapOutsideHandler` when the tap occurs in the `from` frame.
@objc open dynamic var shouldConsiderOriginatingFrameAsPopTip = false
/// A boolean value that determines whether to dismiss when swiping outside the poptip.
@objc open dynamic var shouldDismissOnSwipeOutside = false
/// A boolean value that determines if the action animation should start automatically when the poptip is shown
Expand Down Expand Up @@ -723,7 +726,12 @@ open class PopTip: UIView {
if shouldDismissOnTapOutside {
hide()
}
tapOutsideHandler?(self)

if shouldConsiderOriginatingFrameAsPopTip && from.contains(gesture.location(in: containerView)) {
tapHandler?(self)
} else {
tapOutsideHandler?(self)
}
}

@objc fileprivate func handleSwipeOutside(_ gesture: UITapGestureRecognizer) {
Expand Down

0 comments on commit 747c5ae

Please sign in to comment.