MobileHandlerSingleton
Static Member Summary
Static Private Members | ||
private static |
The maximum layer |
|
private static |
The max number of controllers that can be recycled |
|
private static |
Whether or not an instance can be touched by multiple fingers. |
|
private static |
Whether or not an instance can be touched or not. |
Constructor Summary
Private Constructor | ||
private |
|
Member Summary
Public Members | ||
public |
version: * The version of the module. |
Private Members | ||
private |
An array of all controllers that are active |
|
private |
Weakmap to track data belonging to instances used in this module. |
|
private |
The mobile handler interface that our controllers will exist in |
|
private |
Check if the user agent string contains 'Android' |
|
private |
Check if the user agent string contains 'iPhone' or 'iPad' |
|
private |
Whether this device is mobile or not. |
|
private |
Check if the 'ontouchstart' event is supported |
|
private |
The logger module this module uses to log errors / logs |
|
private |
An object that stores the mapPosition over the screen |
|
private |
An array of all controllers that have been recycled |
|
private |
An array that holds the current screen zones taken, 'left' or 'right'. |
|
private |
An object containing the safe area offset values to account for the notch on notch enabled devices. |
|
private |
An array that holds all the diobs that are currently being touched |
|
private |
An object holding the current window size |
|
private |
The middle of the screen's x coordinate. This is used to figure out which side of the screen is being interacted with. |
|
private |
An object holding the controllers in zones |
Method Summary
Public Methods | ||
public |
createController(pOptions: Object): Controller Creates a controller component with the passed options. |
|
public |
Detects the type of device based on user agent. |
|
public |
Gets the device's current RAM. Only works in a cordova environment. |
|
public |
Short hand for getting the safe area inset for the bottom of the screen. |
|
public |
Short hand for getting the safe area inset for the left of the screen. |
|
public |
Short hand for getting the safe area inset for the right of the screen. |
|
public |
Short hand for getting the safe area inset for the top of the screen. |
|
public |
If this device is an android device. |
|
public |
If this device is an ios device. |
|
public |
If this device is a mobile device. |
|
public |
If this device can register touch events. |
|
public |
|
|
public |
Vibrates the mobile device. |
Private Methods | ||
private |
getDiobUnderFinger(pX: number, pY: number): Object Gets the instance that the user tapped if there was one. |
|
private |
An object containing the safe area offset values to account for the notch on notch enabled devices. |
|
private |
getTrackerObject(pTouchedInstance: Object): Object | void Returns the tracker object associated with pTouchedInstance if it exists. |
|
private |
handleCancel(pEvent: Object) The event function called when a touch is canceled. |
|
private |
The event function called when a touch ends. |
|
private |
handleMove(pEvent: Object) The event function called when a touch is moved. |
|
private |
handleStart(pEvent: Object) The event function called when a touch starts. |
|
private |
handleZoneMove(pX: number, pY: number, pFingerID: string) When a finger on the screen moves, check if the fingerID belongs to a zoned controller, if it does update that zoned controller |
|
private |
handleZoneRelease(pFingerID: string) When a finger on the screen is removed it checks to see if it belongs to a zoned controller. |
|
private |
handleZoneTouch(pX: number, pY: number, pFingerID: string) Handles when a finger is placed onto the screen in a zone |
|
private |
isTracking(pTouchedInstance: Object): boolean Checks if the instance that was touched is being tracked internally. |
|
private |
Queries the safe area inset values set by the device and stores them. |
|
private |
Sets the needed event handlers for this module. |
|
private |
Starts internally tracking this instance. |
|
private |
windowResizeHandler(pWidth: number, pHeight: number) Handler event for when the window resizes. |
Static Private Members
private static MAX_RECYCLED_CONTROLLERS: number source
The max number of controllers that can be recycled
Private Constructors
private constructor() source
Public Members
Private Members
private instanceWeakMap: WeakMap source
Weakmap to track data belonging to instances used in this module.
private interfaceHandle: string source
The mobile handler interface that our controllers will exist in
private reservedScreenZones: Array source
An array that holds the current screen zones taken, 'left' or 'right'.
private safeAreaValues: Object source
An object containing the safe area offset values to account for the notch on notch enabled devices. This will keep the UI in a safe area The safe-area-inset-* variables are four environment variables that define a rectangle by its top, right, bottom, and left insets from the edge of the viewport, which is safe to put content into without risking it being cut off by the shape of a non‑rectangular display. For rectangular viewports, like your average laptop monitor, their value is equal to zero. For non-rectangular displays — like a round watch face — the four values set by the user agent form a rectangle such that all content inside the rectangle is visible. https://developer.mozilla.org/en-US/docs/Web/CSS/env
private touchedInstances: Array source
An array that holds all the diobs that are currently being touched
Public Methods
public createController(pOptions: Object): Controller source
Creates a controller component with the passed options.
Params:
Name | Type | Attribute | Description |
pOptions | Object | The options of this controller. |
|
pOptions.type | string | The way this controller will behave. stationary | traversal | static. |
|
pOptions.size | number | The width/height of the joystick. The width & height of the joystick should be the same. The inner ring will be 50% of this size. |
|
pOptions.position | Object | The initial position of the joystick. |
|
pOptions.position.x | string | The initial x position of the joystick. |
|
pOptions.position.y | string | The initial y position of the joystick. |
|
pOptions.lockedDimension | string | The locked dimension of the joystick. both | vertical | horizontal. This is used to lock the joystick from moving in certain dimensions. If this joystick's type is traversal it cannot be locked. |
|
pOptions.zone | string | The zone the joystick will occupy. If there is already a controller of the traversal or static type, then you must use a zone. If there is only one controller no zone is needed. left | right This will give each controller equal space on the left | right sides of the screen. |
|
pOptions.inactiveAlpha | number | The alpha value the joystick will be when it is considered to be inactive. |
|
pOptions.transitionTime | number | How long it takes in ms to transition to the inactiveAlpha value. |
|
pOptions.scale | number | The scale you want the joystick controller to be. |
|
pOptions.plane | number | The plane of the joystick controller. |
|
pOptions.layer | number | The layer of the joystick controller. |
|
pOptions.atlasName | string | The atlasName of the joystick. |
|
pOptions.joystickIconName | string | The iconName of the joystick. |
|
pOptions.joyringIconName | string | The iconName of the joyring. |
|
pOptions.callback | Object | An object holding options callbacks to attach to events the joystick emits. |
|
pOptions.callback.onTouchBegin | Function | Callback to be called when the joystick is touched after being released. |
|
pOptions.callback.onRelease | Function | Callback to be called when the joystick is released and no longer held. |
|
pOptions.callback.onMove | Function | Callback to be called when the joystick is moved. |
public getDeviceRAM(): number source
Gets the device's current RAM. Only works in a cordova environment.
public getSafeAreaBottom(): number source
Short hand for getting the safe area inset for the bottom of the screen.
public getSafeAreaLeft(): number source
Short hand for getting the safe area inset for the left of the screen.
public getSafeAreaRight(): number source
Short hand for getting the safe area inset for the right of the screen.
public getSafeAreaTop(): number source
Short hand for getting the safe area inset for the top of the screen.
public queryUserAgent() source
public vibrate(pDuration: number) source
Vibrates the mobile device. https://github.com/apache/cordova-plugin-vibration#readme https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API
Params:
Name | Type | Attribute | Description |
pDuration | number | The duration of the vibration. |
Private Methods
private getDiobUnderFinger(pX: number, pY: number): Object source
Gets the instance that the user tapped if there was one.
private getSafeAreaInsets(): Object source
An object containing the safe area offset values to account for the notch on notch enabled devices. This will keep the UI in a safe area The safe-area-inset-* variables are four environment variables that define a rectangle by its top, right, bottom, and left insets from the edge of the viewport, which is safe to put content into without risking it being cut off by the shape of a non‑rectangular display. For rectangular viewports, like your average laptop monitor, their value is equal to zero. For non-rectangular displays — like a round watch face — the four values set by the user agent form a rectangle such that all content inside the rectangle is visible. https://developer.mozilla.org/en-US/docs/Web/CSS/env
private getTrackerObject(pTouchedInstance: Object): Object | void source
Returns the tracker object associated with pTouchedInstance if it exists.
Params:
Name | Type | Attribute | Description |
pTouchedInstance | Object | The instance that needs to be tracked. |
Return:
Object | void | The tracker object associated with pTouchedInstance if it exists. void if not. |
private handleCancel(pEvent: Object) source
The event function called when a touch is canceled.
Params:
Name | Type | Attribute | Description |
pEvent | Object | Represents an event which takes place in the DOM. |
private handleEnd(pEvent: Object) source
The event function called when a touch ends.
Params:
Name | Type | Attribute | Description |
pEvent | Object | Represents an event which takes place in the DOM. |
private handleMove(pEvent: Object) source
The event function called when a touch is moved.
Params:
Name | Type | Attribute | Description |
pEvent | Object | Represents an event which takes place in the DOM. |
private handleStart(pEvent: Object) source
The event function called when a touch starts.
Params:
Name | Type | Attribute | Description |
pEvent | Object | Represents an event which takes place in the DOM. |
private handleZoneMove(pX: number, pY: number, pFingerID: string) source
When a finger on the screen moves, check if the fingerID belongs to a zoned controller, if it does update that zoned controller
private handleZoneRelease(pFingerID: string) source
When a finger on the screen is removed it checks to see if it belongs to a zoned controller. If so it releases that controller.
Params:
Name | Type | Attribute | Description |
pFingerID | string | The ID of the finger. |
private handleZoneTouch(pX: number, pY: number, pFingerID: string) source
Handles when a finger is placed onto the screen in a zone
private isTracking(pTouchedInstance: Object): boolean source
Checks if the instance that was touched is being tracked internally.
Params:
Name | Type | Attribute | Description |
pTouchedInstance | Object | The instance that needs to be tracked. |
private querySafeAreaValues() source
Queries the safe area inset values set by the device and stores them.