Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PopTip is partially displayed outside visible area of screen #133

Closed
akhilcb opened this issue Oct 19, 2017 · 5 comments
Closed

PopTip is partially displayed outside visible area of screen #133

akhilcb opened this issue Oct 19, 2017 · 5 comments

Comments

@akhilcb
Copy link

akhilcb commented Oct 19, 2017

Thanks for the great library. I am trying to use this library to have a poptip without an arrow in my custom view on tap of a button. But for long text, the poptip is partially displayed outside the visible area of screen. This is my sample code:

let popTip = PopTip()
let newFrame = self.convert(sender.frame, to: self.window!)
popTip.show(text: "Hey! Listen! Some test string!", direction: .none, maxWidth: 400, in: self.window!, from: newFrame)

Printing description of newFrame:
▿ (21.3333333333333, 190.0, 70.0, 32.0)

This is how it appears on the screen. How do I make sure that PopTip is always visible on the screen? I can see that if I specify the direction as anything other .none, it works fine.

ampoptipoutsideviewbounds

@andreamazz
Copy link
Owner

Mmmm, good point, I should probably add the same logic in the .none.
Let me see if I can patch this in quickly...

@andreamazz
Copy link
Owner

Ok, that should do the trick. Let me know.

andreamazz added a commit that referenced this issue Oct 19, 2017
@akhilcb
Copy link
Author

akhilcb commented Oct 20, 2017

Thanks for the quick fix. It is working fine. A followup question, is it possible to set some padding to make sure the poptip origin is same as the button from which it appeared?(Right now it is touching the left edge) That way it will look like covering the button completely if I set maxWidth same as button.size.width. Text can wrap into multiple lines below the button too for long text.

@andreamazz
Copy link
Owner

edgeMargin should do the trick

@bennol
Copy link
Contributor

bennol commented Nov 1, 2017

Hi @andreamazz and thanks for the awesome library!
I experienced some weird popover positioning with arrow direction .none after upgrading to 3.0.2 from the Obj-C version.

I tracked down the issue to the rectContained() function that was added recently. I posted a comment with further details at: b9ceeb5

Edit: I figured I should probably just create a pull request. Sorry for the noise. #136

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants