eveningkid/react-native-popable

Idea: auto placement

Closed this issue · 5 comments

I think it would be useful to re-align the popover if the proposed alignment doesn't fit within the screen.

I envision something like this:

Popable alignment

The first situation would actually render the second one. However, if you pass something like strictPlacement, then it doesn't do that.

Let me know what you think. Really excited about this project. Popovers are an important addition to RN, as I mentioned here. I'm glad to see it's being solved.

Right, good idea.

And likewise, it should send it to the bottom if there's not enough room at the top.

I'll work on it shortly and update this issue

Popper-core's placement logic could be an inspiration.

https://github.com/popperjs/popper-core

Thank you @yusufff for sharing. Popper seemed really hardcore on keeping the popover on screen...

For now, Popable will just invert the position if there's not enough room at the given position.
I think it's great since this library should remain minimal.

Again, thanks for raising the issue, it's better this way!

Thoughts on default behavior? I imagine it shouldn't be strict by default, but depends on how much "magic" you think it should have. If strict is default true, I'll just wrap this in my app and make it false.

Agreed, just realised it's actually false by default but I stated it's true in the readme!