observeIntersection sends incorrect rootBounds and boundingClientRect
Please walk through the following steps for reporting an issue about AMP:
Short description of your issue:
Top and bottom of rootBounds change incorrectly as the amp-ad moves within the page. We would expect rootBounds to remain constant. Top and bottom of boundingClientRect do not change, which would expect to change as the amp-ad moves within the page.
For example, this hack fixes the top and bottom of boundingClientRect to be the same as in non-amp pages:
latestIntersection['boundingClientRect']['top'] = latestIntersection['boundingClientRect']['top'] - latestIntersection['rootBounds']['top'];
latestIntersection['boundingClientRect']['bottom'] = latestIntersection['boundingClientRect']['bottom'] - latestIntersection['rootBounds']['bottom'];
How do we reproduce the issue?
Please post a public URL and ideally post a reduced test case. E.g. on jsbin.com that exhibits only your issue and nothing else.
See: http://test.yieldmo.com.s3.amazonaws.com/basak/index-amp_1ad.html (first ad labeled "You may like")
Internally, this uses the event data from observeIntersection to get its position. We would expect the behavior to match this: http://test.yieldmo.com/test/hyperscroller.html
Since this JS needs to be run in the context of an amp ad, making a reduced test case is a little tricky — but let me know if I can help reproduce the issue.
What browsers are affected?
iOS and Android, all browsers
Which AMP version is affected?
Reproducible using amp v. 1474060428356. The behavior seems to have changed recently
Change happened in #4826. I've opened #5131 to fix.