SteffeyDev / react-native-popover-view

A well-tested, adaptable, lightweight <Popover> component for react-native
MIT License
614 stars 92 forks source link

Add ability to offset the popover #127

Closed AdamGerthel closed 2 years ago

AdamGerthel commented 3 years ago

Is your feature request related to a problem? Please describe. Yes, a design problem, but not a technical problem

Describe the solution you'd like I'd like to be able to specify a value (in pixels), similar to the verticalOffset, but which is applied no matter where the placement is. The value should be added as empty space between the start of the arrow and the originating position. I.e. If the value (n) is positive, the popover opens n pixels further away.

Basically, a way to get the popover to start a little bit further away so that it isn't always so close to the from element.

SteffeyDev commented 3 years ago

I'm not sure if this works for your use case, but you could wrap your from element in a View with some padding, which should have the desired effect:

from={(
  <View style={{ padding: 10 }}>
    <InnerElement />
  </View>
)}
SteffeyDev commented 3 years ago

I'm sure there are some cases where adding the padding might mess up the rest of your layout, so let me know if that is the case for you. I try not to add props unless there is not a way to solve the problem outside the library, to keep this library simple and small.

AdamGerthel commented 3 years ago

As you mention yourself, adding padding is not always an option. I also think it's a bit of a dirty workaround.

I'm using popovers in a lot of places like this (with long-press to open it):

Screen Shot 2021-11-09 at 22 07 41

In the above example, I could add padding as a workaround, but not for the buttons at the bottom (which also uses Popover). In my case, I want the exact same offset wherever the popover opens, which is not possible using the suggested solution.

I definitely understand your concern about keeping the library small, but I hope you want it to be small and flexible rather than just small ;)

SteffeyDev commented 3 years ago

Ah yep that does look like a situation where padding wouldn't work. I'll think about the best way to implement this feature.

AdamGerthel commented 3 years ago

Another reason: Visibility. When the popover opens very close to the triggering point, the finger or thumb is often covering parts of the popover. If you slide the finger away to get more space, the popover becomes inactive and closes (if it's done using "press to hold").

SteffeyDev commented 2 years ago

Added an offset prop. This will be fixed when 4.2.0 is released.

SteffeyDev commented 2 years ago

Version 5.0.0 released, which includes the offset prop (I had to release a new major version due to other breaking changes)