-
Notifications
You must be signed in to change notification settings - Fork 144
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
⚗[REPLAY-341] Add VisualViewport tracking (Pinch Zoom) #1118
Conversation
Reopened from #1118 |
Codecov Report
Continue to review full report at Codecov.
|
5005e46
to
50786d9
Compare
init visualviewport FF
Lint fix cleanup
return data support old browsers add debug console Debug cross-browser unit test
PR review updates `window.viewport` breaks build lint
PR review fix
Bump Safari Mobile version to v13 BrowserStack device Block Safari 12 unit test: doesnt support scrollTo within iframes
50786d9
to
e3d75ac
Compare
init visualviewport FF
Lint fix cleanup
return data support old browsers add debug console Debug cross-browser unit test
PR review updates `window.viewport` breaks build lint
PR review fix
Bump Safari Mobile version to v13 BrowserStack device Block Safari 12 unit test: doesnt support scrollTo within iframes
As per IRL discussions: PR drafted while we reprioritise unit testing synthetic gestures (pinch zoom + pinch scroll) via the exposed browser automation hooks in our E2E test suite. |
…rowser-sdk into john.gracey/pinch-zoom-support
Debug E2E test Debug E2E test Debug E2E test Debug E2E test Debug E2E test Debug E2E test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
await browserExecute(() => { | ||
window.dispatchEvent(new Event('resize')) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record: this is to generate a ViewportResize
event without having to explicitly resize the browser (which may be more complex/flaky). LGTM
Motivation
Support pinch zoom and pinch scroll by tracking the "visual viewport".
As mentioned in the internal RFC "Supporting Pinch Zoom Tracking", unfortunately, the dimensions we currently record are not consistent across devices and browsers as some are referenced. On certain devices (primarily mobile), when users pinch zoom, the replay will replay incorrectly- displaying the layout viewport but not the visual viewport.
Unfortunately, browsers have not standardised various dimension properties. Mobile devices typically report dimensions in reference to the visual viewport, while desktop uses the layout viewport. For example, mobile Chrome will change innerWidth when a pinch zoom takes place, while Chrome desktop (mac) will not
With the new Viewport API, we now calculate and normalise dimension properties to the layout viewport.
Note: If the VisualViewport API is not supported by a browser, it isn't reasonably possible to detect or normalise which viewport is being measured. Therefore these exported functions will fallback to assuming that the layout viewport is being measured by the browser
Changes
Testing
To support pinch zoom and pinch scroll unit tests, we use utilise our E2E testing framework to use Appium's gesture commands.
Unfortunately there are many pitfalls to be aware of that required work arounds:
innerWidth
vsvisual.width*scale
appears to differ by 15 pixels likely due to scroll bars.I have gone over the contributing documentation.