Skip to content
pixi-silk
GitHub repository
Class

Island

import { Island } from 'pixi-silk/ui/island';

A surface that grows out of an edge of the viewport, like part of the bezel: a rounded body joined to the edge by concave flares, drawn as one exact shape. It rests as a lip you can pull out and opens on a tap or a drag. It springs between named sizes, so a notch can morph from a lip to a pill to a panel. Content fades in per state.

The main case is a full-screen canvas: pass the Application as viewport. It also sits on the side of a panel (a rectangle) or on the inner edge of an IslandFrame (frame.inner). It redraws only while it moves.

Example#

import { Island, IslandGauge } from 'pixi-silk/ui/island';

const island = new Island({
    viewport: app,
    edge: 'right',
    items: [new IslandGauge({ value: 0.73, color: 0xff5a1f })],
});

app.stage.addChild(island);
island.open();

Extends#

  • Container

Constructors#

Constructor#

new Island(options?: IslandOptions): Island;

Parameters#

ParameterType
optionsIslandOptions

Returns#

Island

Overrides#

Container.constructor

Properties#

PropertyModifierTypeDescriptionDefined in
draggablepublicbooleanPull and push it by dragging.packages/pixi-silk/src/ui/island/Island.ts:185
edgereadonlyIslandEdgeEdge it grows from.packages/pixi-silk/src/ui/island/Island.ts:179
hoverpublicstring | nullState it shows while hovered at rest.packages/pixi-silk/src/ui/island/Island.ts:191
restpublicstringState it goes back to when closed.packages/pixi-silk/src/ui/island/Island.ts:189
stackreadonlyIslandStack | nullThe open content built from items, if any.packages/pixi-silk/src/ui/island/Island.ts:183
statereadonlyIslandStateLive state. Setting state.name moves it.packages/pixi-silk/src/ui/island/Island.ts:181
tapToClosepublicbooleanTap on the island’s own surface while open closes it.packages/pixi-silk/src/ui/island/Island.ts:187

Accessors#

align#

Get Signature#

get align(): number;

Place along the edge, 0..1. Setting it moves the island at once.

Returns

number

Set Signature#

set align(value: number): void;
Parameters
ParameterType
valuenumber
Returns

void


box#

Get Signature#

get box(): IslandRect;

The visible body right now, in the parent’s space: from the edge line to the far side.

Returns

IslandRect


moving#

Get Signature#

get moving(): boolean;

True while it animates.

Returns

boolean


offset#

Get Signature#

get offset(): number;

Extra shift along the edge, local units.

Returns

number

Set Signature#

set offset(value: number): void;
Parameters
ParameterType
valuenumber
Returns

void


shape#

Get Signature#

get shape(): IslandShape | null;

The outline right now, or null while hidden.

Returns

IslandShape | null


states#

Get Signature#

get states(): string[];

Names of the states, shallowest first.

Returns

string[]

Methods#

boxOf()#

boxOf(name: string): {
  height: number;
  width: number;
};

The box a state’s view is laid out in, in screen terms. On the left or right edge the width is the state’s depth. On the top or bottom edge the width is its length.

Parameters#

ParameterType
namestring

Returns#

{
  height: number;
  width: number;
}
NameTypeDefined in
heightnumberpackages/pixi-silk/src/ui/island/Island.ts:377
widthnumberpackages/pixi-silk/src/ui/island/Island.ts:377

close()#

close(): this;

Goes back to the rest state, the lip by default.

Returns#

this


destroy()#

destroy(options?: DestroyOptions): void;

Removes all internal references and listeners as well as removes children from the display list. Do not use a Container after calling destroy.

Parameters#

ParameterTypeDescription
options?DestroyOptionsOptions parameter. A boolean will act as if all options have been set to that value

Returns#

void

Example#

container.destroy();
container.destroy(true);
container.destroy({ children: true });
container.destroy({ children: true, texture: true, textureSource: true });

Overrides#

Container.destroy

flash()#

flash(name: string, ms?: number): this;

Moves to a state, then back to rest after ms: a notification or a live update that shows and leaves. A drag or a tap keeps it where it is. A pointer over it holds it until it leaves.

Parameters#

ParameterTypeDefault value
namestringundefined
msnumber2400

Returns#

this


go()#

go(name: string, instant?: boolean): this;

Moves to a state with the spring. instant jumps there.

Parameters#

ParameterTypeDefault value
namestringundefined
instantbooleanfalse

Returns#

this


hide()#

hide(): this;

Hides it completely.

Returns#

this


hint()#

hint(kind?: IslandHint, strength?: number): this;

Hints that the island can be pulled out: pulse swells it out and back, wiggle shakes it along the edge. A hidden island peeks out for a moment. strength scales it. Default 1.

Parameters#

ParameterTypeDefault value
kindIslandHint'pulse'
strengthnumber1

Returns#

this


open()#

open(): this;

Opens it.

Returns#

this


setSafeArea()#

setSafeArea(insets: IslandInsets): this;

Sets the safe-area insets and redraws.

Parameters#

ParameterType
insetsIslandInsets

Returns#

this


setStateSize()#

setStateSize(name: string, size: IslandSize): this;

Changes the size of a state, or adds one. The island morphs when it is in that state.

Parameters#

ParameterType
namestring
sizeIslandSize

Returns#

this


setViewport()#

setViewport(source: IslandViewport | null): this;

Follows a new viewport and redraws. null stops following.

Parameters#

ParameterType
sourceIslandViewport | null

Returns#

this


sizeOf()#

sizeOf(name: string): IslandSize;

Size of a state. Unknown names give the open size.

Parameters#

ParameterType
namestring

Returns#

IslandSize


tick()#

tick(dt: number): boolean;

Advances the animation by dt seconds (for ticker: null). Returns true while it moves.

Parameters#

ParameterType
dtnumber

Returns#

boolean


toggle()#

toggle(): this;

Opens it at rest, closes it otherwise.

Returns#

this