Skip to content
pixi-silk
GitHub repository
Class

SegmentedSwitch

import { SegmentedSwitch } from 'pixi-silk/ui/modes';

Experimental

A pill of choices with a thumb that slides to the selected one, stretching on the way.

Tap a segment, or press and slide along the pill (the thumb follows the finger and the choice lands on release). Centred on its position. Works for toolbars (select, move, rotate) and for speed or quality settings. Segments cannot be added or removed after construction.

Experimental: the API may change in a minor release.

Extends#

  • Container

Constructors#

Constructor#

new SegmentedSwitch(options: SegmentedSwitchOptions): SegmentedSwitch;

Experimental

Parameters#

ParameterType
optionsSegmentedSwitchOptions

Returns#

SegmentedSwitch

Overrides#

Container.constructor

Properties#

PropertyModifierTypeDescriptionDefined in
statereadonlySegmentedStateExperimental Selected id and enabled flag. Write to them to change the switch.ui/modes.ts:328

Accessors#

switchHeight#

Get Signature#

get switchHeight(): number;

Experimental

Height of the pill.

Returns

number


switchWidth#

Get Signature#

get switchWidth(): number;

Experimental

Width of the pill: the sum of the segment widths.

Returns

number

Methods#

destroy()#

destroy(options?: DestroyOptions): void;

Experimental

Stops the animation. Destroys children unless options says otherwise.

Parameters#

ParameterType
options?DestroyOptions

Returns#

void

Overrides#

Container.destroy

tick()#

tick(dt: number): boolean;

Experimental

Advances the animation by dt seconds (only needed with ticker: null). Returns true while moving.

Parameters#

ParameterType
dtnumber

Returns#

boolean