Skip to content

Toaster

Defined in: ui/Toaster.ts:85

Toaster component that manages the display and positioning of toast notifications.

Example

// Create a toaster
const toaster = new Toaster({
position: 'top right',
maxToasts: 3
});
// Show a basic toast
toaster.show({
message: "Operation successful!",
type: "success"
});
// Show a custom toast
toaster.show({
message: "Custom notification",
backgroundColor: 0x9b59b6,
shadow: {
color: 0x000000,
alpha: 0.2,
offset: { x: 4, y: 4 }
}
});
// Hide all toasts
toaster.hideAll();

Extends

Constructors

new Toaster()

new Toaster(config, defaultToastConfig): Toaster

Defined in: ui/Toaster.ts:180

Create a new Toaster instance to manage toast notifications.

Parameters

config

Partial<ToasterConfig> = {}

Configuration for the Toaster’s position, spacing, and behavior

defaultToastConfig

Partial<ToastConfig> = {}

Default configuration applied to all toasts shown by this Toaster

Returns

Toaster

Example

// Basic toaster with default settings
const toaster = new Toaster();
// Toaster with custom position and behavior
const toaster = new Toaster({
position: 'bottom center',
maxToasts: 3,
spacing: 15,
offset: { x: 20, y: 30 },
stackDirection: 'up'
});
// Toaster with custom defaults for all toasts
const toaster = new Toaster(
{
position: 'top right',
maxToasts: 5
},
{
backgroundColor: 0x000000,
backgroundAlpha: 0.8,
cornerRadius: 8,
shadow: {
color: 0x000000,
alpha: 0.2,
offset: { x: 4, y: 4 }
},
closeButton: {
show: true,
position: 'top right'
}
}
);
// The defaultToastConfig will be applied to all toasts,
// but can be overridden per toast:
toaster.show({ message: "Uses default config" });
toaster.show({
message: "Custom config",
backgroundColor: 0x9b59b6 // Overrides default
});

Overrides

WithSignals(Container).constructor

Properties

__dill_pixel_method_binding_root

__dill_pixel_method_binding_root: boolean = true

Defined in: display/Container.ts:61

Inherited from

WithSignals(Container).__dill_pixel_method_binding_root


add

add: object

Defined in: mixins/factory/Factory.ts:6

animatedSprite()

animatedSprite: (props?) => AnimatedSprite

Parameters
props?

Partial<AnimatedSpriteProps>

Returns

AnimatedSprite

bitmapText()

bitmapText: (props?) => BitmapText

Parameters
props?

Partial<TextProps>

Returns

BitmapText

button()

button: (props?) => Button

Parameters
props?

Partial<ButtonProps>

Returns

Button

container()

container: (props?) => Container<Application<DataSchema, ActionContext, Action, Renderer>>

Parameters
props?

Partial<ContainerProps>

Returns

Container<Application<DataSchema, ActionContext, Action, Renderer>>

existing()

existing: <TEntity>(entity, props?) => TEntity

Type Parameters

TEntity

Parameters
entity

TEntity

props?

Partial<ExistingProps>

Returns

TEntity

flexContainer()

flexContainer: (props?) => FlexContainer

Parameters
props?

Partial<FlexContainerProps>

Returns

FlexContainer

graphics()

graphics: (props?) => Graphics

Parameters
props?

Partial<GraphicsProps>

Returns

Graphics

htmlText()

htmlText: (props?) => HTMLText

Parameters
props?

Partial<HTMLTextProps>

Returns

HTMLText

particleContainer()

particleContainer: (props?) => ParticleContainer<Application<DataSchema, ActionContext, Action, Renderer>>

Parameters
props?

Partial<ParticleContainerProps>

Returns

ParticleContainer<Application<DataSchema, ActionContext, Action, Renderer>>

spine()

spine: (props?) => Spine

Parameters
props?

Partial<SpineProps>

Returns

Spine

spineAnimation()

spineAnimation: (props?) => SpineAnimation

Parameters
props?

Partial<SpineProps>

Returns

SpineAnimation

sprite()

sprite: (props?) => Sprite

Parameters
props?

Partial<SpriteProps>

Returns

Sprite

text()

text: (props?) => Text

Parameters
props?

Partial<TextProps>

Returns

Text

texture()

texture: (props?) => Texture = resolveTexture

Parameters
props?

Partial<TextureProps>

Returns

Texture

tilingSprite()

tilingSprite: (props?) => TilingSprite

Parameters
props?

Partial<TilingSpriteProps>

Returns

TilingSprite

toaster()

toaster: (toasterConfig?, defaultToastConfig) => Toaster

Parameters
toasterConfig?

Partial<ToasterConfig>

defaultToastConfig?

Partial<ToastConfig> = {}

Returns

Toaster

uiCanvas()

uiCanvas: (props?) => UICanvas

Parameters
props?

Partial<UICanvasFactoryProps>

Returns

UICanvas

svg()

Parameters
props

WithRequiredProps<SvgProps, "ctx">

Returns

Svg

Inherited from

WithSignals(Container).add


config

config: ToasterConfig

Defined in: ui/Toaster.ts:93


defaultToastConfig

defaultToastConfig: Partial<ToastConfig>

Defined in: ui/Toaster.ts:94


make

make: object

Defined in: mixins/factory/Factory.ts:7

animatedSprite()

animatedSprite: (props?) => AnimatedSprite

Parameters
props?

Partial<AnimatedSpriteProps>

Returns

AnimatedSprite

bitmapText()

bitmapText: (props?) => BitmapText

Parameters
props?

Partial<TextProps>

Returns

BitmapText

button()

button: (props?) => Button

Parameters
props?

Partial<ButtonProps>

Returns

Button

container()

container: (props?) => Container<Application<DataSchema, ActionContext, Action, Renderer>>

Parameters
props?

Partial<ContainerProps>

Returns

Container<Application<DataSchema, ActionContext, Action, Renderer>>

existing()

existing: <TEntity>(entity, props?) => TEntity

Type Parameters

TEntity

Parameters
entity

TEntity

props?

Partial<ExistingProps>

Returns

TEntity

flexContainer()

flexContainer: (props?) => FlexContainer

Parameters
props?

Partial<FlexContainerProps>

Returns

FlexContainer

graphics()

graphics: (props?) => Graphics

Parameters
props?

Partial<GraphicsProps>

Returns

Graphics

htmlText()

htmlText: (props?) => HTMLText

Parameters
props?

Partial<HTMLTextProps>

Returns

HTMLText

particleContainer()

particleContainer: (props?) => ParticleContainer<Application<DataSchema, ActionContext, Action, Renderer>>

Parameters
props?

Partial<ParticleContainerProps>

Returns

ParticleContainer<Application<DataSchema, ActionContext, Action, Renderer>>

spine()

spine: (props?) => Spine

Parameters
props?

Partial<SpineProps>

Returns

Spine

spineAnimation()

spineAnimation: (props?) => SpineAnimation

Parameters
props?

Partial<SpineProps>

Returns

SpineAnimation

sprite()

sprite: (props?) => Sprite

Parameters
props?

Partial<SpriteProps>

Returns

Sprite

text()

text: (props?) => Text

Parameters
props?

Partial<TextProps>

Returns

Text

texture()

texture: (props?) => Texture = resolveTexture

Parameters
props?

Partial<TextureProps>

Returns

Texture

tilingSprite()

tilingSprite: (props?) => TilingSprite

Parameters
props?

Partial<TilingSpriteProps>

Returns

TilingSprite

toaster()

toaster: (toasterConfig?, defaultToastConfig) => Toaster

Parameters
toasterConfig?

Partial<ToasterConfig>

defaultToastConfig?

Partial<ToastConfig> = {}

Returns

Toaster

uiCanvas()

uiCanvas: (props?) => UICanvas

Parameters
props?

Partial<UICanvasFactoryProps>

Returns

UICanvas

svg()

Parameters
props

WithRequiredProps<SvgProps, "ctx">

Returns

Svg

Inherited from

WithSignals(Container).make


onAllToastsRemoved

readonly onAllToastsRemoved: Signal<() => void>

Defined in: ui/Toaster.ts:91

Emitted when all toasts are removed


onAnimationComplete

onAnimationComplete: Signal<(entity) => void>

Defined in: mixins/animated.ts:21

Inherited from

WithSignals(Container).onAnimationComplete


onAnimationStart

onAnimationStart: Signal<(entity) => void>

Defined in: mixins/animated.ts:19

Inherited from

WithSignals(Container).onAnimationStart


onAnimationUpdate

onAnimationUpdate: Signal<(entity) => void>

Defined in: mixins/animated.ts:20

Inherited from

WithSignals(Container).onAnimationUpdate


onDestroy

onDestroy: Signal<() => void>

Defined in: display/Container.ts:60

Inherited from

WithSignals(Container).onDestroy


onToastAdded

readonly onToastAdded: Signal<(toast) => void>

Defined in: ui/Toaster.ts:87

Emitted when a new toast is added


onToastRemoved

readonly onToastRemoved: Signal<(toast) => void>

Defined in: ui/Toaster.ts:89

Emitted when a toast is removed


signalConnections

signalConnections: SignalConnections

Defined in: mixins/signals.ts:9

Inherited from

WithSignals(Container).signalConnections

Accessors

app

Get Signature

get app(): A

Defined in: display/Container.ts:82

Get the application instance.

Returns

A

Inherited from

WithSignals(Container).app


maxToasts

Get Signature

get maxToasts(): number

Defined in: ui/Toaster.ts:121

Returns

number


offset

Get Signature

get offset(): number | { x: number; y: number; }

Defined in: ui/Toaster.ts:117

Returns

number | { x: number; y: number; }


size

Get Signature

get size(): number

Defined in: ui/Toaster.ts:101

Get the current number of visible toasts

Returns

number


spacing

Get Signature

get spacing(): number

Defined in: ui/Toaster.ts:113

Returns

number


stackDirection

Get Signature

get stackDirection(): "up" | "down"

Defined in: ui/Toaster.ts:109

Returns

"up" | "down"


toastConfig

Get Signature

get toastConfig(): Partial<ToastConfig>

Defined in: ui/Toaster.ts:125

Returns

Partial<ToastConfig>


toastPosition

Get Signature

get toastPosition(): UICanvasEdge

Defined in: ui/Toaster.ts:105

Returns

UICanvasEdge

Methods

addColoredBackground()

addColoredBackground(colorOrConfig, alpha): Sprite

Defined in: display/Container.ts:86

Parameters

colorOrConfig

number | Partial<BackgroundConfig>

alpha

number = 1

Returns

Sprite

Inherited from

WithSignals(Container).addColoredBackground


added()

added(): void

Defined in: display/Container.ts:145

This method is called when the container is added to the stage. It is meant to be overridden by subclasses.

Returns

void

Inherited from

WithSignals(Container).added


addSignalConnection()

addSignalConnection(…args): void

Defined in: mixins/signals.ts:13

Parameters

args

SignalConnection[]

Returns

void

Inherited from

WithSignals(Container).addSignalConnection


animate()

animate(animationProps, instance?): Tween

Defined in: mixins/animated.ts:23

Parameters

animationProps

GSAPAnimationConfigExtended

instance?

any

Returns

Tween

Inherited from

WithSignals(Container).animate


animateFrom()

animateFrom(animationProps, instance?): Tween

Defined in: mixins/animated.ts:25

Parameters

animationProps

GSAPAnimationConfigExtended

instance?

any

Returns

Tween

Inherited from

WithSignals(Container).animateFrom


animateFromTo()

animateFromTo(fromProps, toProps, instance?): Tween

Defined in: mixins/animated.ts:27

Parameters

fromProps

GSAPAnimationConfigExtended

toProps

GSAPAnimationConfigExtended

instance?

any

Returns

Tween

Inherited from

WithSignals(Container).animateFromTo


animateSequence()

animateSequence(sequences, instance?): Timeline

Defined in: mixins/animated.ts:33

Parameters

sequences

GSAPAnimationConfigExtended[]

instance?

any

Returns

Timeline

Inherited from

WithSignals(Container).animateSequence


bob()

bob(config?, instance?): Tween

Defined in: mixins/animated.ts:50

Parameters

config?
duration?

number

intensity?

number

instance?

any

Returns

Tween

Inherited from

WithSignals(Container).bob


connectAction()

connectAction(…args): void

Defined in: mixins/signals.ts:15

Parameters

args

SignalConnection[]

Returns

void

Inherited from

WithSignals(Container).connectAction


connectSignal()

connectSignal(…args): void

Defined in: mixins/signals.ts:14

Parameters

args

SignalConnection[]

Returns

void

Inherited from

WithSignals(Container).connectSignal


destroy()

destroy(): void

Defined in: ui/Toaster.ts:399

Returns

void

Overrides

WithSignals(Container).destroy


destroyAnimations()

destroyAnimations(): void

Defined in: mixins/animated.ts:39

Returns

void

Inherited from

WithSignals(Container).destroyAnimations


hideAll()

hideAll(): Promise<void>

Defined in: ui/Toaster.ts:260

Hide all currently visible toasts with animation

Returns

Promise<void>

Promise that resolves when all toasts are hidden


isAnimationPlaying()

isAnimationPlaying(): boolean

Defined in: mixins/animated.ts:43

Returns

boolean

Inherited from

WithSignals(Container).isAnimationPlaying


pauseAnimations()

pauseAnimations(): void

Defined in: mixins/animated.ts:35

Returns

void

Inherited from

WithSignals(Container).pauseAnimations


positionToasts()

positionToasts(animate, skipLast): void

Defined in: ui/Toaster.ts:304

Update positions of all toasts

Parameters

animate

boolean = true

Whether to animate the position changes

skipLast

boolean = false

Whether to skip positioning the last toast

Returns

void


pulse()

pulse(config?, instance?): Tween

Defined in: mixins/animated.ts:48

Parameters

config?
duration?

number

intensity?

number

times?

number

instance?

any

Returns

Tween

Inherited from

WithSignals(Container).pulse


removeAll()

removeAll(): Promise<void>

Defined in: ui/Toaster.ts:273

Remove all toasts (alias for hideAll)

Returns

Promise<void>


removed()

removed(): void

Defined in: display/Container.ts:155

Returns

void

Inherited from

WithSignals(Container).removed


resize()

resize(): void

Defined in: ui/Toaster.ts:394

Handle window resize events

Returns

void

Overrides

WithSignals(Container).resize


resumeAnimations()

resumeAnimations(): void

Defined in: mixins/animated.ts:37

Returns

void

Inherited from

WithSignals(Container).resumeAnimations


reverseAnimation()

reverseAnimation(): void

Defined in: mixins/animated.ts:41

Returns

void

Inherited from

WithSignals(Container).reverseAnimation


shake()

shake(config?, instance?): Tween

Defined in: mixins/animated.ts:46

Parameters

config?
duration?

number

intensity?

number

times?

number

instance?

any

Returns

Tween

Inherited from

WithSignals(Container).shake


show()

show(config, overrideDefaults): Promise<Toast>

Defined in: ui/Toaster.ts:197

Display a new toast notification

Parameters

config

Partial<ToastConfig> = ...

Configuration for the toast to display

overrideDefaults

boolean = false

Returns

Promise<Toast>

Promise that resolves with the created toast


update()

update(ticker?): void

Defined in: display/Container.ts:130

Update the container. This method is meant to be overridden by subclasses.

Parameters

ticker?

number | Ticker

Returns

void

Inherited from

WithSignals(Container).update