Class: Puppeteer::TouchScreen
- Inherits:
-
Object
- Object
- Puppeteer::TouchScreen
- Defined in:
- lib/puppeteer/touch_screen.rb
Instance Method Summary collapse
- #async_tap ⇒ Future
-
#initialize(client, keyboard) ⇒ TouchScreen
constructor
A new instance of TouchScreen.
- #tap(x, y) ⇒ Object
Constructor Details
#initialize(client, keyboard) ⇒ TouchScreen
Returns a new instance of TouchScreen.
6 7 8 9 |
# File 'lib/puppeteer/touch_screen.rb', line 6 def initialize(client, keyboard) @client = client @keyboard = keyboard end |
Instance Method Details
#async_tap ⇒ Future
40 41 42 |
# File 'lib/puppeteer/touch_screen.rb', line 40 async def async_tap(x, y) tap(x, y) end |
#tap(x, y) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppeteer/touch_screen.rb', line 13 def 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 @client.('Runtime.evaluate', expression: 'new Promise(x => requestAnimationFrame(() => requestAnimationFrame(x)))', awaitPromise: true, ) touch_points = [ { x: x.round, y: y.round }, ] @client.('Input.dispatchTouchEvent', type: 'touchStart', touchPoints: touch_points, modifiers: @keyboard.modifiers, ) @client.('Input.dispatchTouchEvent', type: 'touchEnd', touchPoints: [], modifiers: @keyboard.modifiers, ) end |