mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: DRY up mouse.click() (#9725)
This commit is contained in:
parent
9910aae2f7
commit
81bf443789
@ -478,18 +478,14 @@ export class Mouse {
|
|||||||
options: MouseOptions & {delay?: number} = {}
|
options: MouseOptions & {delay?: number} = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const {delay = null} = options;
|
const {delay = null} = options;
|
||||||
|
await this.move(x, y);
|
||||||
|
await this.down(options);
|
||||||
if (delay !== null) {
|
if (delay !== null) {
|
||||||
await this.move(x, y);
|
|
||||||
await this.down(options);
|
|
||||||
await new Promise(f => {
|
await new Promise(f => {
|
||||||
return setTimeout(f, delay);
|
return setTimeout(f, delay);
|
||||||
});
|
});
|
||||||
await this.up(options);
|
|
||||||
} else {
|
|
||||||
await this.move(x, y);
|
|
||||||
await this.down(options);
|
|
||||||
await this.up(options);
|
|
||||||
}
|
}
|
||||||
|
await this.up(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user