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#
| Parameter | Type |
|---|---|
options | IslandOptions |
Returns#
Island
Overrides#
Container.constructor
Properties#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
draggable | public | boolean | Pull and push it by dragging. | packages/pixi-silk/src/ui/island/Island.ts:185 |
edge | readonly | IslandEdge | Edge it grows from. | packages/pixi-silk/src/ui/island/Island.ts:179 |
hover | public | string | null | State it shows while hovered at rest. | packages/pixi-silk/src/ui/island/Island.ts:191 |
rest | public | string | State it goes back to when closed. | packages/pixi-silk/src/ui/island/Island.ts:189 |
stack | readonly | IslandStack | null | The open content built from items, if any. | packages/pixi-silk/src/ui/island/Island.ts:183 |
state | readonly | IslandState | Live state. Setting state.name moves it. | packages/pixi-silk/src/ui/island/Island.ts:181 |
tapToClose | public | boolean | Tap 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
| Parameter | Type |
|---|---|
value | number |
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
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
| Parameter | Type |
|---|---|
value | number |
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#
| Parameter | Type |
|---|---|
name | string |
Returns#
{
height: number;
width: number;
}
| Name | Type | Defined in |
|---|---|---|
height | number | packages/pixi-silk/src/ui/island/Island.ts:377 |
width | number | packages/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#
| Parameter | Type | Description |
|---|---|---|
options? | DestroyOptions | Options 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#
| Parameter | Type | Default value |
|---|---|---|
name | string | undefined |
ms | number | 2400 |
Returns#
this
go()#
go(name: string, instant?: boolean): this;
Moves to a state with the spring. instant jumps there.
Parameters#
| Parameter | Type | Default value |
|---|---|---|
name | string | undefined |
instant | boolean | false |
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#
| Parameter | Type | Default value |
|---|---|---|
kind | IslandHint | 'pulse' |
strength | number | 1 |
Returns#
this
open()#
open(): this;
Opens it.
Returns#
this
setSafeArea()#
setSafeArea(insets: IslandInsets): this;
Sets the safe-area insets and redraws.
Parameters#
| Parameter | Type |
|---|---|
insets | IslandInsets |
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#
| Parameter | Type |
|---|---|
name | string |
size | IslandSize |
Returns#
this
setViewport()#
setViewport(source: IslandViewport | null): this;
Follows a new viewport and redraws. null stops following.
Parameters#
| Parameter | Type |
|---|---|
source | IslandViewport | null |
Returns#
this
sizeOf()#
sizeOf(name: string): IslandSize;
Size of a state. Unknown names give the open size.
Parameters#
| Parameter | Type |
|---|---|
name | string |
Returns#
tick()#
tick(dt: number): boolean;
Advances the animation by dt seconds (for ticker: null). Returns true while it moves.
Parameters#
| Parameter | Type |
|---|---|
dt | number |
Returns#
boolean
toggle()#
toggle(): this;
Opens it at rest, closes it otherwise.
Returns#
this