chore: format

This commit is contained in:
Nathan Walker
2020-07-05 14:57:06 -07:00
parent 8f2900ad0b
commit da3c0b973d
379 changed files with 71587 additions and 54582 deletions

View File

@@ -1,148 +1,156 @@
import { GestureEventData as GestureEventData, GesturesObserver as GesturesObserverDefinition } from ".";
import {
GestureEventData,
GesturesObserver as GesturesObserverDefinition,
} from ".";
import { View } from "../core/view";
export enum GestureTypes {
tap = 1 << 0,
doubleTap = 1 << 1,
pinch = 1 << 2,
pan = 1 << 3,
swipe = 1 << 4,
rotation = 1 << 5,
longPress = 1 << 6,
touch = 1 << 7
tap = 1 << 0,
doubleTap = 1 << 1,
pinch = 1 << 2,
pan = 1 << 3,
swipe = 1 << 4,
rotation = 1 << 5,
longPress = 1 << 6,
touch = 1 << 7,
}
export enum GestureStateTypes {
cancelled,
began,
changed,
ended
cancelled,
began,
changed,
ended,
}
export enum SwipeDirection {
right = 1 << 0,
left = 1 << 1,
up = 1 << 2,
down = 1 << 3
right = 1 << 0,
left = 1 << 1,
up = 1 << 2,
down = 1 << 3,
}
export module TouchAction {
export const down = "down";
export const up = "up";
export const move = "move";
export const cancel = "cancel";
export const down = "down";
export const up = "up";
export const move = "move";
export const cancel = "cancel";
}
export function toString(type: GestureTypes, separator?: string): string {
let types = new Array<string>();
let types = new Array<string>();
if (type & GestureTypes.tap) {
types.push("tap");
}
if (type & GestureTypes.tap) {
types.push("tap");
}
if (type & GestureTypes.doubleTap) {
types.push("doubleTap");
}
if (type & GestureTypes.doubleTap) {
types.push("doubleTap");
}
if (type & GestureTypes.pinch) {
types.push("pinch");
}
if (type & GestureTypes.pinch) {
types.push("pinch");
}
if (type & GestureTypes.pan) {
types.push("pan");
}
if (type & GestureTypes.pan) {
types.push("pan");
}
if (type & GestureTypes.swipe) {
types.push("swipe");
}
if (type & GestureTypes.swipe) {
types.push("swipe");
}
if (type & GestureTypes.rotation) {
types.push("rotation");
}
if (type & GestureTypes.rotation) {
types.push("rotation");
}
if (type & GestureTypes.longPress) {
types.push("longPress");
}
if (type & GestureTypes.longPress) {
types.push("longPress");
}
if (type & GestureTypes.touch) {
types.push("touch");
}
if (type & GestureTypes.touch) {
types.push("touch");
}
return types.join(separator);
return types.join(separator);
}
// NOTE: toString could return the text of multiple GestureTypes.
// Souldn't fromString do split on separator and return multiple GestureTypes?
export function fromString(type: string): GestureTypes {
let t = type.trim().toLowerCase();
let t = type.trim().toLowerCase();
if (t === "tap") {
return GestureTypes.tap;
} else if (t === "doubletap") {
return GestureTypes.doubleTap;
} else if (t === "pinch") {
return GestureTypes.pinch;
} else if (t === "pan") {
return GestureTypes.pan;
} else if (t === "swipe") {
return GestureTypes.swipe;
} else if (t === "rotation") {
return GestureTypes.rotation;
} else if (t === "longpress") {
return GestureTypes.longPress;
} else if (t === "touch") {
return GestureTypes.touch;
}
if (t === "tap") {
return GestureTypes.tap;
} else if (t === "doubletap") {
return GestureTypes.doubleTap;
} else if (t === "pinch") {
return GestureTypes.pinch;
} else if (t === "pan") {
return GestureTypes.pan;
} else if (t === "swipe") {
return GestureTypes.swipe;
} else if (t === "rotation") {
return GestureTypes.rotation;
} else if (t === "longpress") {
return GestureTypes.longPress;
} else if (t === "touch") {
return GestureTypes.touch;
}
return undefined;
return undefined;
}
export abstract class GesturesObserverBase implements GesturesObserverDefinition {
private _callback: (args: GestureEventData) => void;
private _target: View;
private _context: any;
export abstract class GesturesObserverBase
implements GesturesObserverDefinition {
private _callback: (args: GestureEventData) => void;
private _target: View;
private _context: any;
public type: GestureTypes;
public type: GestureTypes;
public get callback(): (args: GestureEventData) => void {
return this._callback;
}
public get callback(): (args: GestureEventData) => void {
return this._callback;
}
public get target(): View {
return this._target;
}
public get target(): View {
return this._target;
}
public get context() {
return this._context;
}
public get context() {
return this._context;
}
constructor(target: View, callback: (args: GestureEventData) => void, context: any) {
this._target = target;
this._callback = callback;
this._context = context;
}
constructor(
target: View,
callback: (args: GestureEventData) => void,
context: any
) {
this._target = target;
this._callback = callback;
this._context = context;
}
public abstract androidOnTouchEvent(motionEvent: android.view.MotionEvent);
public abstract observe(type: GestureTypes);
public abstract androidOnTouchEvent(motionEvent: android.view.MotionEvent);
public abstract observe(type: GestureTypes);
public disconnect() {
// remove gesture observer from map
if (this.target) {
let list = this.target.getGestureObservers(this.type);
if (list && list.length > 0) {
for (let i = 0; i < list.length; i++) {
if (list[i].callback === this.callback) {
break;
}
}
list.length = 0;
public disconnect() {
// remove gesture observer from map
if (this.target) {
let list = this.target.getGestureObservers(this.type);
if (list && list.length > 0) {
for (let i = 0; i < list.length; i++) {
if (list[i].callback === this.callback) {
break;
}
}
list.length = 0;
this.target._gestureObservers[this.type] = undefined;
delete this.target._gestureObservers[this.type];
}
}
this._target = null;
this._callback = null;
this._context = null;
}
this.target._gestureObservers[this.type] = undefined;
delete this.target._gestureObservers[this.type];
}
}
this._target = null;
this._callback = null;
this._context = null;
}
}

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,324 +1,334 @@
import { View } from "../core/view";
import { EventData } from "../../data/observable";
/**
* Defines an enum with supported gesture types.
*/
export enum GestureTypes {
/**
* Denotes tap (click) gesture.
*/
tap,
/**
* Denotes double tap gesture.
*/
doubleTap,
/**
* Denotes pinch gesture.
*/
pinch,
/**
* Denotes pan gesture.
*/
pan,
/**
* Denotes swipe gesture.
*/
swipe,
/**
* Denotes rotation gesture.
*/
rotation,
/**
* Denotes long press gesture.
*/
longPress,
/**
* Denotes touch action.
*/
touch
}
/**
* Defines an enum with supported gesture types.
*/
export enum GestureTypes {
/**
* Denotes tap (click) gesture.
*/
tap,
/**
* Denotes double tap gesture.
*/
doubleTap,
/**
* Denotes pinch gesture.
*/
pinch,
/**
* Denotes pan gesture.
*/
pan,
/**
* Denotes swipe gesture.
*/
swipe,
/**
* Denotes rotation gesture.
*/
rotation,
/**
* Denotes long press gesture.
*/
longPress,
/**
* Denotes touch action.
*/
touch,
}
/**
* Defines an enum with supported gesture states.
*/
export enum GestureStateTypes {
/**
* Gesture canceled.
*/
cancelled,
/**
* Gesture began.
*/
began,
/**
* Gesture changed.
*/
changed,
/**
* Gesture ended.
*/
ended
}
/**
* Defines an enum with supported gesture states.
*/
export enum GestureStateTypes {
/**
* Gesture canceled.
*/
cancelled,
/**
* Gesture began.
*/
began,
/**
* Gesture changed.
*/
changed,
/**
* Gesture ended.
*/
ended,
}
/**
* Defines an enum for swipe gesture direction.
*/
export enum SwipeDirection {
/**
* Denotes right direction for swipe gesture.
*/
right,
/**
* Denotes left direction for swipe gesture.
*/
left,
/**
* Denotes up direction for swipe gesture.
*/
up,
/**
* Denotes down direction for swipe gesture.
*/
down
}
/**
* Defines an enum for swipe gesture direction.
*/
export enum SwipeDirection {
/**
* Denotes right direction for swipe gesture.
*/
right,
/**
* Denotes left direction for swipe gesture.
*/
left,
/**
* Denotes up direction for swipe gesture.
*/
up,
/**
* Denotes down direction for swipe gesture.
*/
down,
}
/**
* Defines a touch action
*/
export module TouchAction {
/**
* Down action.
*/
export const down: string;
/**
* Defines a touch action
*/
export module TouchAction {
/**
* Down action.
*/
export const down: string;
/**
* Up action.
*/
export const up: string;
/**
* Up action.
*/
export const up: string;
/**
* Move action.
*/
export const move: string;
/**
* Move action.
*/
export const move: string;
/**
* Cancel action.
*/
export const cancel: string;
}
/**
* Cancel action.
*/
export const cancel: string;
}
/**
* Provides gesture event data.
*/
export interface GestureEventData extends EventData {
/**
* Gets the type of the gesture.
*/
type: GestureTypes;
/**
* Gets the view which originates the gesture.
*/
view: View;
/**
* Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/).
*/
ios: any /* UIGestureRecognizer */;
/**
* Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html).
*/
android: any
}
/**
* Provides gesture event data.
*/
export interface GestureEventData extends EventData {
/**
* Gets the type of the gesture.
*/
type: GestureTypes;
/**
* Gets the view which originates the gesture.
*/
view: View;
/**
* Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/).
*/
ios: any /* UIGestureRecognizer */;
/**
* Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html).
*/
android: any;
}
/**
* Provides gesture event data.
*/
/**
* Provides gesture event data.
*/
export interface TapGestureEventData extends GestureEventData {
/**
* Gets the number of pointers in the event.
*/
getPointerCount(): number;
/**
* Gets the X coordinate of this event inside the view that triggered the event
*/
getX(): number;
/**
* Gets the Y coordinate of the event inside the view that triggered the event.
*/
getY(): number;
/**
* Gets the number of pointers in the event.
*/
getPointerCount(): number;
/**
* Gets the X coordinate of this event inside the view that triggered the event
*/
getX(): number;
/**
* Gets the Y coordinate of the event inside the view that triggered the event.
*/
getY(): number;
}
}
/**
* Provides gesture event data.
*/
export interface TouchGestureEventData extends TapGestureEventData {
/**
* Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
*/
action: "up" | "move" | "down" | "cancel";
/**
* Gets the pointers that triggered the event.
* Note: In Android there is aways only one active pointer.
*/
getActivePointers(): Array<Pointer>;
/**
* Provides gesture event data.
*/
export interface TouchGestureEventData extends TapGestureEventData {
/**
* Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
*/
action: "up" | "move" | "down" | "cancel";
/**
* Gets the pointers that triggered the event.
* Note: In Android there is aways only one active pointer.
*/
getActivePointers(): Array<Pointer>;
/**
* Gets all pointers.
*/
getAllPointers(): Array<Pointer>;
}
/**
* Gets all pointers.
*/
getAllPointers(): Array<Pointer>;
}
/**
* Pointer is an object representing a finger (or other object) that is touching the screen.
*/
export interface Pointer {
/**
* The id of the pointer.
*/
android: any;
/**
* Pointer is an object representing a finger (or other object) that is touching the screen.
*/
export interface Pointer {
/**
* The id of the pointer.
*/
android: any;
/**
* The UITouch object associated to the touch
*/
ios: any;
/**
* The UITouch object associated to the touch
*/
ios: any;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
*/
getX(): number;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
*/
getX(): number;
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
*/
getY(): number;
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
*/
getY(): number;
/**
* Gests the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Pixels_.
*/
getXPixels(): number;
/**
* Gests the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Pixels_.
*/
getXPixels(): number
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Independent Pixels_.
*/
getXDIP(): number;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Independent Pixels_.
*/
getXDIP(): number
/**
* Gests the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Pixels_.
*/
getYPixels(): number;
/**
* Gests the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Pixels_.
*/
getYPixels(): number
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Independent Pixels_.
*/
getYDIP(): number;
}
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Independent Pixels_.
*/
getYDIP(): number
}
/**
* Provides gesture event data.
*/
export interface GestureEventDataWithState extends GestureEventData {
state: number;
}
/**
* Provides gesture event data.
*/
export interface GestureEventDataWithState extends GestureEventData {
state: number;
}
/**
* Provides gesture event data for pinch gesture.
*/
export interface PinchGestureEventData extends GestureEventDataWithState {
scale: number;
/**
* Provides gesture event data for pinch gesture.
*/
export interface PinchGestureEventData extends GestureEventDataWithState {
scale: number;
getFocusX(): number;
getFocusY(): number;
}
getFocusX(): number;
getFocusY(): number;
}
/**
* Provides gesture event data for swipe gesture.
*/
export interface SwipeGestureEventData extends GestureEventData {
direction: SwipeDirection;
}
/**
* Provides gesture event data for swipe gesture.
*/
export interface SwipeGestureEventData extends GestureEventData {
direction: SwipeDirection;
}
/**
* Provides gesture event data for pan gesture.
*/
export interface PanGestureEventData extends GestureEventDataWithState {
deltaX: number;
deltaY: number;
}
/**
* Provides gesture event data for pan gesture.
*/
export interface PanGestureEventData extends GestureEventDataWithState {
deltaX: number;
deltaY: number;
}
/**
* Provides gesture event data for rotation gesture.
*/
export interface RotationGestureEventData extends GestureEventDataWithState {
rotation: number;
}
/**
* Provides gesture event data for rotation gesture.
*/
export interface RotationGestureEventData extends GestureEventDataWithState {
rotation: number;
}
/**
* Provides options for the GesturesObserver.
*/
export class GesturesObserver {
/**
* Creates an instance of GesturesObserver class.
* @param target - The view for which the observer is created.
* @param callback - A function that will be executed when a gesture is received.
* @param context - default this argument for the callbacks.
*/
constructor(
target: View,
callback: (args: GestureEventData) => void,
context: any
);
/**
* Provides options for the GesturesObserver.
*/
export class GesturesObserver {
/**
* Creates an instance of GesturesObserver class.
* @param target - The view for which the observer is created.
* @param callback - A function that will be executed when a gesture is received.
* @param context - default this argument for the callbacks.
*/
constructor(target: View, callback: (args: GestureEventData) => void, context: any);
/**
* Registers a gesture observer to a view and gesture.
* @param type - Type of the gesture.
*/
observe(type: GestureTypes);
/**
* Registers a gesture observer to a view and gesture.
* @param type - Type of the gesture.
*/
observe(type: GestureTypes);
/**
* Disconnects the gesture observer.
*/
disconnect();
/**
* Disconnects the gesture observer.
*/
disconnect();
/**
* Gesture type attached to the observer.
*/
type: GestureTypes;
/**
* Gesture type attached to the observer.
*/
type: GestureTypes;
/**
* A function that will be executed when a gesture is received.
*/
callback: (args: GestureEventData) => void;
/**
* A function that will be executed when a gesture is received.
*/
callback: (args: GestureEventData) => void;
/**
* A context which will be used as `this` in callback execution.
*/
context: any;
/**
* A context which will be used as `this` in callback execution.
*/
context: any;
/**
* An internal Android specific method used to pass the motion event to the correct gesture observer.
*/
androidOnTouchEvent: (
motionEvent: any /* android.view.MotionEvent */
) => void;
}
/**
* An internal Android specific method used to pass the motion event to the correct gesture observer.
*/
androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void;
}
/**
* A short-hand function that is used to create a gesture observer for a view and gesture.
* @param target - View which will be watched for originating a specific gesture.
* @param type - Type of the gesture.
* @param callback - A function that will be executed when a gesture is received.
* @param context - this argument for the callback.
*/
export function observe(
target: View,
type: GestureTypes,
callback: (args: GestureEventData) => void,
context?: any
): GesturesObserver;
/**
* A short-hand function that is used to create a gesture observer for a view and gesture.
* @param target - View which will be watched for originating a specific gesture.
* @param type - Type of the gesture.
* @param callback - A function that will be executed when a gesture is received.
* @param context - this argument for the callback.
*/
export function observe(target: View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver;
/**
* Returns a string representation of a gesture type.
* @param type - Type of the gesture.
* @param separator(optional) - Text separator between gesture type strings.
*/
export function toString(type: GestureTypes, separator?: string): string;
/**
* Returns a string representation of a gesture type.
* @param type - Type of the gesture.
* @param separator(optional) - Text separator between gesture type strings.
*/
export function toString(type: GestureTypes, separator?: string): string;
/**
* Returns a gesture type enum value from a string (case insensitive).
* @param type - A string representation of a gesture type (e.g. Tap).
*/
export function fromString(type: string): GestureTypes;
/**
* Returns a gesture type enum value from a string (case insensitive).
* @param type - A string representation of a gesture type (e.g. Tap).
*/
export function fromString(type: string): GestureTypes;

View File

File diff suppressed because it is too large Load Diff