mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(touch): requestAnimationFrame before sending tap (#1142)
This patch adds a work-around for the upstream bug, issuing double-raf before emulating touch event. References #673
This commit is contained in:
parent
d1f044e18f
commit
655b94db47
@ -281,6 +281,14 @@ class Touchscreen {
|
||||
* @param {number} y
|
||||
*/
|
||||
async tap(x, y) {
|
||||
// Touches appear to be lost during the first frame after navigation.
|
||||
// This waits a frame before sending the tap.
|
||||
// @see https://crbug.com/613219
|
||||
await this._client.send('Runtime.evaluate', {
|
||||
expression: 'new Promise(x => requestAnimationFrame(() => requestAnimationFrame(x)))',
|
||||
awaitPromise: true
|
||||
});
|
||||
|
||||
const touchPoints = [{x: Math.round(x), y: Math.round(y)}];
|
||||
await this._client.send('Input.dispatchTouchEvent', {
|
||||
type: 'touchStart',
|
||||
|
Loading…
Reference in New Issue
Block a user