Skip to content

Commit 7953e11

Browse files
Rename SwipeDirection to Direction
1 parent a6cc749 commit 7953e11

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export { ElementHelper } from "./lib/element-helper";
33
export { UIElement } from "./lib/ui-element";
44
export { Point } from "./lib/point";
55
export { SearchOptions } from "./lib/search-options";
6-
export { SwipeDirection } from "./lib/swipe-direction";
6+
export { Direction } from "./lib/direction";
77
export declare function startServer(port?: number): Promise<void>;
88
export declare function stopServer(): Promise<void>;
99
export declare function createDriver(): Promise<any>;

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export { ElementHelper } from "./lib/element-helper";
1010
export { UIElement } from "./lib/ui-element";
1111
export { Point } from "./lib/point";
1212
export { SearchOptions } from "./lib/search-options";
13-
export { SwipeDirection } from "./lib/swipe-direction";
13+
export { Direction } from "./lib/direction";
1414

1515
const nsCapabilities = new NsCapabilities();
1616
const appiumServer = new AppiumServer(nsCapabilities);

lib/appium-driver.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export declare var should: any;
22
import { ElementHelper } from "./element-helper";
33
import { SearchOptions } from "./search-options";
44
import { UIElement } from "./ui-element";
5-
import { SwipeDirection } from "./swipe-direction";
5+
import { Direction } from "./direction";
66
import { INsCapabilities } from "./ins-capabilities";
77
import { Point } from "./point";
88
export declare class AppiumDriver {
@@ -93,7 +93,7 @@ export declare class AppiumDriver {
9393
* @param xOffset
9494
* @param retryCount
9595
*/
96-
scrollToElement(direction: SwipeDirection, element: any, startPoint: Point, yOffset: number, xOffset?: number, retryCount?: number): Promise<any>;
96+
scrollToElement(direction: Direction, element: any, startPoint: Point, yOffset: number, xOffset?: number, retryCount?: number): Promise<any>;
9797
/**
9898
* Swipe from point with offset and inertia according to duatio
9999
* @param y

lib/appium-driver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { searchCustomCapabilities } from "./capabilities-helper";
1010
import { ElementHelper } from "./element-helper";
1111
import { SearchOptions } from "./search-options";
1212
import { UIElement } from "./ui-element";
13-
import { SwipeDirection } from "./swipe-direction";
13+
import { Direction } from "./direction";
1414
import {
1515
log,
1616
getStorage,
@@ -176,7 +176,7 @@ export class AppiumDriver {
176176
* @param xOffset
177177
* @param retryCount
178178
*/
179-
public async scrollToElement(direction: SwipeDirection, element: any, startPoint: Point, yOffset: number, xOffset: number = 0, retryCount: number = 7) {
179+
public async scrollToElement(direction: Direction, element: any, startPoint: Point, yOffset: number, xOffset: number = 0, retryCount: number = 7) {
180180
let el = null
181181
while (el === null && retryCount > 0) {
182182
try {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export declare const enum SwipeDirection {
1+
export declare const enum Direction {
22
down = 0,
33
up = 1,
44
left = 2,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const enum SwipeDirection {
1+
export const enum Direction {
22
down,
33
up,
44
left,

lib/ui-element.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Point } from "./point";
2-
import { SwipeDirection } from "./swipe-direction";
2+
import { Direction } from "./direction";
33
export declare class UIElement {
44
private _element;
55
private _driver;
@@ -59,7 +59,7 @@ export declare class UIElement {
5959
* @param yOffset
6060
* @param xOffset
6161
*/
62-
scroll(direction: SwipeDirection, yOffset: number, xOffset?: number): Promise<void>;
62+
scroll(direction: Direction, yOffset: number, xOffset?: number): Promise<void>;
6363
log(): Promise<void>;
6464
refetch(): Promise<any>;
6565
}

lib/ui-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Point } from "./point";
2-
import { SwipeDirection } from "./swipe-direction";
2+
import { Direction } from "./direction";
33
import { calculateOffset } from "./utils";
44

55
export class UIElement {
@@ -96,7 +96,7 @@ export class UIElement {
9696
* @param yOffset
9797
* @param xOffset
9898
*/
99-
public async scroll(direction: SwipeDirection, yOffset: number, xOffset: number = 0) {
99+
public async scroll(direction: Direction, yOffset: number, xOffset: number = 0) {
100100
//await this._driver.execute("mobile: scroll", [{direction: 'up'}])
101101
//await this._driver.execute('mobile: scroll', { direction: direction === 0 ? "down" : "up", element: this._element.ELEMENT });
102102
const location = await this.location();

lib/utils.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { INsCapabilities } from "./ins-capabilities";
22
import { Point } from "./point";
3-
import { SwipeDirection } from "./swipe-direction";
3+
import { Direction } from "./direction";
44
export declare function resolve(mainPath: any, ...args: any[]): any;
55
export declare function fileExists(p: any): boolean;
66
export declare function isFile(fullName: any): boolean;
@@ -31,4 +31,4 @@ export declare function calculateOffset(direction: any, y: number, yOffset: numb
3131
* @param duration
3232
* @param xOffset
3333
*/
34-
export declare function scroll(wd: any, driver: any, direction: SwipeDirection, isIOS: boolean, y: number, x: number, yOffset: number, xOffset: number, verbose: any): Promise<void>;
34+
export declare function scroll(wd: any, driver: any, direction: Direction, isIOS: boolean, y: number, x: number, yOffset: number, xOffset: number, verbose: any): Promise<void>;

lib/utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as glob from "glob";
66
require('colors');
77
import { INsCapabilities } from "./ins-capabilities";
88
import { Point } from "./point";
9-
import { SwipeDirection } from "./swipe-direction";
9+
import { Direction } from "./direction";
1010

1111
export function resolve(mainPath, ...args) {
1212
if (!path.isAbsolute(mainPath)) {
@@ -292,29 +292,29 @@ export function calculateOffset(direction, y: number, yOffset: number, x: number
292292

293293
if (isIOS) {
294294
speed = 100;
295-
if (direction === SwipeDirection.down) {
295+
if (direction === Direction.down) {
296296
direction = -1;
297297
yEnd = direction * yEnd;
298298
}
299-
if (direction === SwipeDirection.right) {
299+
if (direction === Direction.right) {
300300
direction = -1;
301301
xEnd = direction * xEnd;
302302
}
303303
} else {
304-
if (direction === SwipeDirection.down) {
304+
if (direction === Direction.down) {
305305
yEnd = Math.abs(yOffset - y);
306306
}
307-
if (direction === SwipeDirection.up) {
307+
if (direction === Direction.up) {
308308
yEnd = direction * Math.abs((Math.abs(yOffset) + y));
309309
}
310310

311311
duration = Math.abs(yOffset) * speed;
312312

313-
if (direction === SwipeDirection.right) {
313+
if (direction === Direction.right) {
314314
xEnd = Math.abs(xOffset - x);
315315
}
316316

317-
if (direction === SwipeDirection.left) {
317+
if (direction === Direction.left) {
318318
xEnd = Math.abs(xOffset + x);
319319
}
320320

@@ -336,7 +336,7 @@ export function calculateOffset(direction, y: number, yOffset: number, x: number
336336
* @param duration
337337
* @param xOffset
338338
*/
339-
export async function scroll(wd, driver, direction: SwipeDirection, isIOS: boolean, y: number, x: number, yOffset: number, xOffset: number, verbose) {
339+
export async function scroll(wd, driver, direction: Direction, isIOS: boolean, y: number, x: number, yOffset: number, xOffset: number, verbose) {
340340
if (x === 0) {
341341
x = 20;
342342
}

0 commit comments

Comments
 (0)