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

measureInWindow inaccurate in Safari #1037

Closed
davepack opened this issue Jul 13, 2018 · 3 comments
Closed

measureInWindow inaccurate in Safari #1037

davepack opened this issue Jul 13, 2018 · 3 comments
Milestone

Comments

@davepack
Copy link

davepack commented Jul 13, 2018

The problem
Chrome/Firefox: node.scroll[Top|Left] when node is body is always 0, so window page[Y|X]Offset should be used in place of node.scroll[Top|Left] for only the body node.

Safari: measureInWindow is off by the sum of top and left borders of all parents.

How to reproduce
App here demonstrates the issue: https://rnw-measureinwindow.glitch.me/
Try it in Safari and Chrome/Firefox.

Code: https://glitch.com/edit/#!/rnw-measureinwindow?path=src/components/App/index.js

Steps to reproduce:

  1. open glitch app
  2. scroll through the two scroll views
  3. click "come here square" buttons

Expected behavior
The blue square should cover the pink square completely to demonstrate that measureInWindow measured the pink square correctly.

Environment (include versions). Did this work in previous versions?

  • React Native for Web (version): 0.8.8
  • React (version): 16.4
  • Browser:
    • Safari 11.1.1
    • Chrome 67.0.3396.99
    • Firefox 61.0.1

I started a PR here: #955
Demo of this PR in use: http://davepack.com/rnw-scroll-measure-test/
Source for demo: https://github.com/davepack/rnw-scroll-measure-test/blob/master/src/App.js

I either need guidance and further understanding of edge cases that the getRect() function needs to meet, or somebody else needs to complete my work.

Thanks!

@necolas
Copy link
Owner

necolas commented Jul 13, 2018

Note that body scrolling isn't supported at this time

@davepack davepack reopened this Jul 15, 2018
@necolas necolas changed the title measureInWindow broken in Chrome/Firefox, inaccurate in Safari measureInWindow inaccurate in Safari Jul 27, 2018
@necolas necolas added this to the 0.10.0 milestone Dec 31, 2018
necolas added a commit that referenced this issue Jan 1, 2019
@necolas
Copy link
Owner

necolas commented Jan 1, 2019

I think this should be fixed by the patch above and will be in the 0.10 release.

@MoOx
Copy link
Contributor

MoOx commented Jan 30, 2019

FYI, I used View measure method and it was working in Safari, but totally not in Chrome/Firefox (same origin of the bug).

I used this method to simply load something when it's appearing on screen (via a simple viewport observer component)

With the fix shipped (I am using 0.10.0-alpha.3), it's perfectly working as expected in all browsers. Thanks @necolas!

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