ContextHalo
import { ContextHalo } from 'pixi-silk/ui/halo';
Experimental
Action buttons orbiting the selected object. It follows the target every frame from its bounds,
so it tracks drags, tweens and camera moves. The buttons sit on an arc hugging the target’s box,
on the preferred side. When that side would leave bounds the arc turns to the side with the
most room. Buttons pop in with a stagger and pop out on detach().
Attach it to a target with attach(target). Keep the halo in a space that is not scaled by a
camera, so the buttons keep their size. The target is measured by its axis-aligned bounds.
Experimental: the API may change in a minor release.
Extends#
Container
Constructors#
Constructor#
new ContextHalo(options: ContextHaloOptions): ContextHalo;
Experimental
Parameters#
| Parameter | Type |
|---|---|
options | ContextHaloOptions |
Returns#
ContextHalo
Overrides#
Container.constructor
Properties#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
state | readonly | HaloState | Experimental Target, hover, drag and pop phase, as signals. | ui/halo.ts:142 |
Accessors#
hideWhileDragging#
Get Signature#
get hideWhileDragging(): boolean;
Experimental
Folds the buttons away while state.dragging is true. Can change at any time.
Returns
boolean
Set Signature#
set hideWhileDragging(value: boolean): void;
Experimental
Parameters
| Parameter | Type |
|---|---|
value | boolean |
Returns
void
positions#
Get Signature#
get positions(): {
id: string;
x: number;
y: number;
}[];
Experimental
Where each button is heading, in the halo’s coordinates, for tests and custom drawing. Allocates.
Returns
{
id: string;
x: number;
y: number;
}[]
Methods#
attach()#
attach(target: Container): void;
Experimental
Starts orbiting target. From another target the buttons pop out there and in here, or glide
with transition: 'glide'. Moves the halo to the top of its parent’s children.
Parameters#
| Parameter | Type |
|---|---|
target | Container |
Returns#
void
destroy()#
destroy(options?: DestroyOptions): void;
Experimental
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
detach()#
detach(): void;
Experimental
Pops the buttons out and lets go of the target. state.target is null at once.
Returns#
void
setItems()#
setItems(items: HaloItem[]): void;
Experimental
Replaces the actions. Destroys the old icons, so do not share icon containers between halos.
Parameters#
| Parameter | Type |
|---|---|
items | HaloItem[] |
Returns#
void
tick()#
tick(dt: number): boolean;
Experimental
Advances the animation by dt seconds (clamped to 0..0.1). Only needed with ticker: null. Returns true while moving.
Parameters#
| Parameter | Type |
|---|---|
dt | number |
Returns#
boolean