Class MobileHandlerSingleton

Constructors

Properties

MULTI_TOUCH: number = 2

Whether or not an instance can be touched by multiple fingers. If their touchOpacity is set to MULTI_TOUCH it can be interacted with multiple times via different touches.

NO_TOUCH: number = 0

Whether or not an instance can be touched or not. If their touchOpacity is set to NO_TOUCH, it cannot be touched

MAX_RECYCLED_CONTROLLERS: number = 10

The max number of controllers that can be recycled

MAX_LAYER: number = 1999998

The maximum layer

recycledControllers: Controller[] = []

An array of all controllers that have been recycled

activeControllers: Controller[] = []

An array of all controllers that are active

zonedControllers: {
    [key: string]: Controller | null;
} = {}

An object holding the controllers in zones

Type declaration

touchedInstances: any[] = []

An array that holds all the diobs that are currently being touched

mapPositionObject: MapPositionObject = ...

An object that stores the mapPosition over the screen

reservedScreenZones: string[] = []

An array that holds the current screen zones taken, 'left' or 'right'.

windowSize: WindowSize = ...

An object holding the current window size

xCenterScreenPosition: number = ...

The middle of the screen's x coordinate. This is used to figure out which side of the screen is being interacted with.

instanceWeakMap: WeakMap<any, TrackerObject> = ...

Weakmap to track data belonging to instances used in this module.

version: string = "VERSION_REPLACE_ME"

The version of the module.

logger: any

The logger module this module uses to log errors / logs

interfaceHandle: string

The mobile handler interface that our controllers will exist in

safeAreaValues: SafeAreaValues = ...

An object containing the safe area offset values to account for the notch on notch enabled devices.

isIOS: boolean = false

Check if the user agent string contains 'iPhone' or 'iPad'

isAndroid: boolean = false

Check if the user agent string contains 'Android'

isTouchEnabled: boolean = false

Check if the 'ontouchstart' event is supported

isMobile: boolean = false

Whether this device is mobile or not. Can be simulated.

Methods

  • An object containing the safe area inset 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

    Returns SafeAreaValues

    The safe area inset values

  • Short hand for getting the safe area inset for the top of the screen.

    Returns number

    The safe area top inset

  • Short hand for getting the safe area inset for the bottom of the screen.

    Returns number

    The safe area bottom inset

  • Short hand for getting the safe area inset for the left of the screen.

    Returns number

    The safe area left inset

  • Short hand for getting the safe area inset for the right of the screen.

    Returns number

    The safe area right inset

  • Detects the type of device based on user agent.

    Returns "desktop" | "mobile"

    The detected device type ('desktop' or 'mobile').

  • If this device can register touch events.

    Returns boolean

    Whether this device is a touch enabled device.

  • If this device is a mobile device.

    Returns boolean

    Whether this device is a mobile device.

  • If this device is an ios device.

    Returns boolean

    Whether this device is an ios device.

  • If this device is an android device.

    Returns boolean

    Whether this device is an android device.

  • Gets the device's current RAM. Only works in a cordova environment.

    Returns undefined | number

    The device's current RAM

  • Handler event for when the window resizes.

    Parameters

    • pWidth: number

      The window's new width.

    • pHeight: number

      The window's new height.

    Returns void

  • Gets the instance that the user tapped if there was one.

    Parameters

    • pX: number

      The x position on the screen where the user tapped.

    • pY: number

      The y position on the screen where the user tapped.

    Returns any

    The instance that was tapped or null if nothing was touched.

  • Sets the needed event handlers for this module.

    Returns void

  • Queries the safe area inset values set by the device and stores them.

    Returns void

  • Starts internally tracking this instance.

    Parameters

    • pTouchedInstance: any

      The instance that needs to be tracked.

    Returns void

  • Checks if the instance that was touched is being tracked internally.

    Parameters

    • pTouchedInstance: any

      The instance that needs to be tracked.

    Returns boolean

    Whether pTouchedInstance is being tracked.

  • Returns the tracker object associated with pTouchedInstance if it exists.

    Parameters

    • pTouchedInstance: any

      The instance that needs to be tracked.

    Returns undefined | TrackerObject

    The tracker object associated with pTouchedInstance if it exists. undefined if not.

  • Handles when a finger is placed onto the screen in a zone

    Parameters

    • pX: number

      The x position on the screen where the user tapped.

    • pY: number

      The y position on the screen where the user tapped.

    • pFingerID: number

      The ID of the finger

    Returns void

  • 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.

    Parameters

    • pFingerID: number

      The ID of the finger.

    Returns void

  • When a finger on the screen moves, check if the fingerID belongs to a zoned controller, if it does update that zoned controller

    Parameters

    • pX: number

      The x position on the screen where the user tapped.

    • pY: number

      The y position on the screen where the user tapped.

    • pFingerID: number

      The ID of the finger

    Returns void

  • The event function called when a touch starts.

    Parameters

    • pEvent: TouchEvent

      Represents an event which takes place in the DOM.

    Returns void

  • The event function called when a touch ends.

    Parameters

    • pEvent: TouchEvent

      Represents an event which takes place in the DOM.

    Returns void

  • The event function called when a touch is canceled.

    Parameters

    • pEvent: TouchEvent

      Represents an event which takes place in the DOM.

    Returns void

  • The event function called when a touch is moved.

    Parameters

    • pEvent: TouchEvent

      Represents an event which takes place in the DOM.

    Returns void