SteffeyDev / react-native-popover-view

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

Fix tooltip positioning #101

Closed tecno40 closed 3 years ago

tecno40 commented 3 years ago

I tested the change in commit 1d273d3 and it looks like there was a small issue with it. I also found my original understanding of the problem was incorrect. Here's an updated fix and a better explanation.

tecno40 commented 3 years ago

Was FIX_SHIFT purposely off by an increment of 1 to offset for the driver issue? Maybe the driver has since been fixed, or it only applies to certain versions of react native?

SteffeyDev commented 3 years ago

That's a decent explanation of what is going on, but out of date since the last commit. I now replaced all the FIX_SHIFT * 2 with FIX_SHIFT, which should bring everything in sync. I don't want styles.container to contain the shift for consistency reasons.

The shift was the result of hours of debugging an issue with useNativeDriver, where it would flash the popover on and off really quickly, and then animate in normally. Now, because of the shift, the flash happens off screen, and then it is shifted on screen just before beginning the actual animation. I'm unsure of what versions and platforms it is happening on, but if you have the time, you are welcome to remove it and test on a variety of combinations to see if it still occurs. I would love to get rid of it if it is no longer an issue.

SteffeyDev commented 3 years ago

See if this commit fixes it. I won't have time to test until the weekend unfortunately.

tecno40 commented 3 years ago

I didn't do a comprehensive test, but it does seem to be working from the areas I tested.

tecno40 commented 3 years ago

While reading over the code again I noticed FIX_SHIFT is being set to the window height via export var FIX_SHIFT = Dimensions.get('window').height * 2; Could this potentially create an issue when they rotate the phone as the height would change, or does the x 2 end up taking care of that in most cases? I did go and look at a few phones screen sizes and it looks like the width is generally half the height. Sometimes it's a bit less, but it's generally only off by a few pixels in those cases.