Skip to content

Commit a04e134

Browse files
committed
(#53) Updated to new API
1 parent 25e1414 commit a04e134

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/mouse.class.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NativeAdapter } from "./adapter/native.adapter.class";
22
import { Button } from "./button.enum";
3-
import { MovementType } from "./movementtype.class";
3+
import { linear } from "./movementtype.function";
44
import { Point } from "./point.class";
55
import { sleep } from "./sleep.function";
66

@@ -29,12 +29,13 @@ export class Mouse {
2929
return this.native.currentMousePosition();
3030
}
3131

32-
public async move(path: Point[], movementType = MovementType.linear): Promise<Mouse> {
32+
public async move(path: Point[] | Promise<Point[]>, movementType = linear): Promise<Mouse> {
3333
return new Promise<Mouse>(async (resolve, reject) => {
3434
try {
35-
const timeSteps = movementType(path.length, this.config.mouseSpeed);
36-
for (let idx = 0; idx < path.length; ++idx) {
37-
const node = path[idx];
35+
const pathSteps = await path;
36+
const timeSteps = movementType(pathSteps.length, this.config.mouseSpeed);
37+
for (let idx = 0; idx < pathSteps.length; ++idx) {
38+
const node = pathSteps[idx];
3839
const minTime = timeSteps[idx];
3940
await sleep(minTime);
4041
await this.native.setMousePosition(node);
@@ -114,7 +115,7 @@ export class Mouse {
114115
});
115116
}
116117

117-
public async drag(path: Point[]): Promise<Mouse> {
118+
public async drag(path: Point[] | Promise<Point[]>): Promise<Mouse> {
118119
return new Promise<Mouse>(async (resolve, reject) => {
119120
try {
120121
await sleep(this.config.autoDelayMs);

0 commit comments

Comments
 (0)