-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
TouchScreen.tap #639
TouchScreen.tap #639
Conversation
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.
overall looks good!
lib/ElementHandle.js
Outdated
@@ -112,6 +114,10 @@ class ElementHandle { | |||
return await this.evaluate((element, key) => element.getAttribute(key), key); | |||
} | |||
|
|||
async tap() { |
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.
jsdoc
docs/api.md
Outdated
#### elementHandle.tap() | ||
- returns: <[Promise]> Promise which resolves when the element is successfully tapped. Promise gets rejected if the element is detached from DOM. | ||
|
||
This method scrolls element into view if needed, and then uses [touchScreen.tap](#touchscreentapx-y) to tap in the center of the element. |
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.
can we explain what's a tap?
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.
A concise and effective definition: https://api.jquerymobile.com/tap
docs/api.md
Outdated
@@ -81,6 +82,8 @@ | |||
+ [mouse.down([options])](#mousedownoptions) | |||
+ [mouse.move(x, y, [options])](#mousemovex-y-options) | |||
+ [mouse.up([options])](#mouseupoptions) | |||
* [class: TouchScreen](#class-touchscreen) |
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.
can we also have page.tap()
similarly to page.click()
?
docs/api.md
Outdated
@@ -64,6 +64,7 @@ | |||
+ [page.setUserAgent(userAgent)](#pagesetuseragentuseragent) | |||
+ [page.setViewport(viewport)](#pagesetviewportviewport) | |||
+ [page.title()](#pagetitle) | |||
+ [page.touchScreen](#pagetouchscreen) |
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.
the page.touchScreen feels slightly weird. Paul, any naming ideas? @paulirish
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.
we can do page.touchscreen
, all lowercase because apparently touchscreen is one word
<script src="mouse-helper.js"></script> | ||
<button onclick="clicked();">Click target</button> | ||
<script> | ||
window.result = []; |
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.
don't we have the same asset for mouse? Can we unify the two, simply recording all the events for the button?
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.
There is a similar one for keyboard, but it has a textarea.
@@ -1497,6 +1497,18 @@ describe('Page', function() { | |||
[200, 300] | |||
]); | |||
})); | |||
it('should tap the button', SX(async function() { | |||
await page.goto(PREFIX + '/input/button.html'); |
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.
is is actually ok to send touches to the non-touch viewport?
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.
It seems fine.
9dc6510
to
e3fbbbe
Compare
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.
Great patch, thanks.
await page.goto(PREFIX + '/input/touches.html'); | ||
const button = await page.$('button'); | ||
await button.tap(); | ||
expect(await page.evaluate(() => getResult())).toEqual(['Touchstart: 0', 'Touchend: 0']); |
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.
Out of curiosity, how's getResult()
different from result
? You use one in the first test and other in the second
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.
it clears the result
I am waiting for swipe function,It may only be used now |
@JoelEinbinder thanks for your payout, how about the swipe, pinch and zoom events? when are they will be released? |
@JoelEinbinder Is swipe ready yet? |
it looks like no yet!! |
This adds a touchScreen input object with a
tap
method, and an equivalenttap
on elementHandle. In the future touchScreen with have methods likeswipe
,pinch
andzoom
. The other methods are waiting on some backend work to make them less racy.#568 #569 #158