Interface JoystickConfig

interface JoystickConfig {
    catchDistance?: number;
    color?: string;
    dataOnly?: boolean;
    dynamicPage?: boolean;
    fadeTime?: number;
    follow?: boolean;
    lockX?: boolean;
    lockY?: boolean;
    maxNumberOfNipples?: number;
    mode?: "static" | "dynamic" | "semi";
    multitouch?: boolean;
    position?: {
        bottom?: string;
        left?: string;
        right?: string;
        top?: string;
    };
    restJoystick?: boolean | RestJoystickOption;
    restOpacity?: number;
    shape?: "circle" | "square";
    size?: number;
    threshold?: number;
    zone?: HTMLElement;
}

Hierarchy

  • JoystickManagerOptions
    • JoystickConfig

Properties

catchDistance?: number

Defaults to 200

This is only useful in the semi mode, and determine at which distance we recycle the previous joystick.

color?: string

Defaults to 'white' The background color of your joystick’s elements.

Can be any valid CSS color.

dataOnly?: boolean

Defaults to false

The library won’t draw anything in the DOM and will only trigger events with data.

dynamicPage?: boolean

Defaults to false

Enable if the page has dynamically visible elements such as for Vue, React, Angular or simply some CSS hiding or showing some DOM.

fadeTime?: number

Defaults to 250

The time it takes for joystick to fade-out and fade-in when activated or de-activated.

follow?: boolean

Defaults to false

Make the joystick follow the cursor beyond its limits.

lockX?: boolean

Defaults to false

Locks joystick’s movement to the x (horizontal) axis

lockY?: boolean

Defaults to false

Locks joystick’s movement to the y (vertical) axis

maxNumberOfNipples?: number

Defaults to 1

If you need to, you can also control the maximum number of instance that could be created.

Obviously in a multitouch configuration.

mode?: "static" | "dynamic" | "semi"

Behavioral mode for the joystick

a new joystick is created at each new touch. the joystick gets destroyed when released. can be multitouch.

new joystick is created at each new touch farther than options.catchDistance of any previously created joystick. the joystick is faded-out when released but not destroyed. when touch is made inside the options.catchDistance a new direction is triggered immediately. when touch is made outside the options.catchDistance the previous joystick is destroyed and a new one is created. cannot be multitouch.

a joystick is positioned immediately at options.position. one joystick per zone. each new touch triggers a new direction. cannot be multitouch.

multitouch?: boolean

Defaults to false

Enable the multitouch capabilities.

If, for reasons, you need to have multiple nipples into the same zone.

Otherwise it will only get one, and all new touches won’t do a thing.

Please note that multitouch is off when in static or semi modes.

position?: {
    bottom?: string;
    left?: string;
    right?: string;
    top?: string;
}

Defaults to {top: 0, left: 0}

An object that will determine the position of a static mode.

You can pass any of the four top, right, bottom and left.

They will be applied as any css property.

restJoystick?: boolean | RestJoystickOption

Defaults to true

Reset the joystick’s position when it enters the rest state.

restOpacity?: number

Defaults to 0.5 The opacity to apply when the joystick is in a rest position.

shape?: "circle" | "square"

Defaults to circle

Sets the shape of the joystick

size?: number

Defaults to 100 The size in pixel of the outer circle.

The inner circle is 50% of this size.

threshold?: number

This is the strength needed to trigger a directional event.

Basically, the center is 0 and the outer is 1.

You need to at least go to 0.1 to trigger a directional event.

zone?: HTMLElement

Defaults to 'body' The dom element in which all your joysticks will be injected.

This zone also serve as the mouse/touch events handler.

It represents the zone where all your joysticks will be active.