Skip to content
pixi-silk
GitHub repository
Class

CounterBlock

import { CounterBlock } from 'pixi-silk/ui/blocks';

A number that counts to its signal’s value with an ease-out, a frame at a time, then lets the surface sleep. Each value it shows is laid out once and cached.

Extends#

Constructors#

Constructor#

new CounterBlock(options: CounterBlockOptions): CounterBlock;

Parameters#

ParameterType
optionsCounterBlockOptions

Returns#

CounterBlock

Overrides#

Block.constructor

Properties#

PropertyModifierTypeDescriptionInherited fromDefined in
hpublicnumberHeight of the slot, design units. The layout sets it.Block.hpackages/pixi-silk/src/ui/blocks.ts:86
layerreadonlyBlockLayerThe layer it asked for. See BlockOptions.layer.Block.layerpackages/pixi-silk/src/ui/blocks.ts:88
shownpublicnumberThe number shown now.-packages/pixi-silk/src/ui/blocks.ts:751
wpublicnumberWidth of the slot, design units. The layout sets it.Block.wpackages/pixi-silk/src/ui/blocks.ts:84

Accessors#

surface#

Get Signature#

get surface(): BlockSurface | null;

The surface the block is in, or null.

Returns

BlockSurface | null

Inherited from#

Block.surface

Methods#

destroy()#

destroy(options?: DestroyOptions): void;

Stops following watched signals.

Parameters#

ParameterType
options?DestroyOptions

Returns#

void

Inherited from#

Block.destroy


layout()#

layout(style?: SmartLayout): SmartLayout;

The flex style of this block’s slot: its size, no shrinking, and an onSize that keeps w and h in step with the layout. An absolute slot stretched between two edges (inset, or left and right) takes its size from them instead. Pass it to add of a FlexContainer or SmartContainer.

Parameters#

ParameterType
styleSmartLayout

Returns#

SmartLayout

Inherited from#

Block.layout


paint()#

paint(
   g: SilkGraphics, 
   x: number, 
   y: number
): void;

Draws the block into g with its slot’s top-left corner at (x, y), in the surface’s space.

Parameters#

ParameterType
gSilkGraphics
xnumber
ynumber

Returns#

void

Overrides#

Block.paint


step()#

step(dt: number): boolean;

Advances the block’s springs by dt seconds. Returns true while any moves. Override it to animate something else, and return true while that runs.

Parameters#

ParameterType
dtnumber

Returns#

boolean

Overrides#

Block.step


wake()#

wake(): void;

Asks the surface to repaint this block. The surface repaints until every block settles, then sleeps. The first call moves an 'auto' block to the live layer.

Returns#

void

Inherited from#

Block.wake