Skip to content

Fix tooltip positioning #101

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

Closed
wants to merge 2 commits into from

Conversation

tecno40
Copy link

@tecno40 tecno40 commented Apr 15, 2021

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.

  • Line 328 in Popover.tsx was shifted by -1 * FIX_SHIFT <View pointerEvents="box-none" style={styles.container} (styles.container originally had a -1 * FIX_SHIFT as part of it)
  • Line 1162 in Popover.tsx was shifted by -1 * FIX_SHIFT <View pointerEvents="box-none" style={[styles.container, { top: -1 * FIX_SHIFT }]}>
  • Line 1170 in Popover.tsx was shifted by -1 * FIX_SHIFT <Animated.View pointerEvents="box-none" style={containerStyle}> (styles.container originally had a -1 * FIX_SHIFT as part of it)
  • The means the popover is shifted by -3 * FIX_SHIFT, but all the calculations try to shift it by 2 * FIX_SHIFT, so we have an extra -1 * FIX_SHIFT
  • The proper place to fix this is on line 328, in order to make JSModalPopover (line 305) and RNModalPopover (line 229 - which has no extra -1 * FIX_SHIFT) equal
  • Commit 1d273d3 did fix the issue on line 328, but it accidentally removed the -1 * FIX_SHIFT at line 1170, which we still need
  • This PR adds the -1 * FIX_SHIFT back to the containerStyle which line 1170 references

tecno40 and others added 2 commits April 14, 2021 22:53
@tecno40 tecno40 force-pushed the fix-tooltip-positioning branch from 2babe8c to 198df4a Compare April 15, 2021 06:44
@tecno40
Copy link
Author

tecno40 commented Apr 15, 2021

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
Copy link
Owner

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
Copy link
Owner

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

@tecno40
Copy link
Author

tecno40 commented Apr 16, 2021

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

@tecno40
Copy link
Author

tecno40 commented Apr 16, 2021

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.

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

Successfully merging this pull request may close these issues.

3 participants