Skip to content

@aninest/extensions / Update / UpdateLayer

UpdateLayer<Animating> ​

ts
type UpdateLayer<Animating> = Layer<Animating> & object;

Defined in: ../../extensions/src/update.ts:80

An update layer that can be mounted to an animation. Allows listening to:

  • start - when any child animation starts to be updated,
  • update - when any child animation is updated
  • updateWithDeltaTime - each update frame with the time since the last update
  • afterUpdate - after each update frame
  • childStart - when a child UpdateLayer starts to be updated
  • childEnd - when a child UpdateLayer finishes animating everything, including its children
  • done - when the animation finishes animating everything and pauses the updates

Type declaration ​

forceUpdate() ​

ts
forceUpdate: (dt) => void;

Forces update. Useful to force rerendering/running afterUpdate event listeners. Recommended to call with 0 as the value for dt.

Parameters ​

dt ​

number

Returns ​

void

setParent() ​

ts
setParent: (parentLayer, options?) => unsubscribe;

Will mount the current update layer onto another update layer so that the other layer will drive the updates to this layer rather than those updates being driven by triggerNextUpdate. This layer will only drive its "start" and "end" events. The other layer will listen to the "start" event of this layer.

Parameters ​

parentLayer ​

UpdateLayer<UnknownAnimatable>

options? ​

SignalOption

Returns ​

unsubscribe

subscribe() ​

ts
subscribe<Event>(
   type, 
   sub, 
   options?): unsubscribe;

Type Parameters ​

Event ​

Event extends | "start" | "end" | "update" | "updateWithDeltaTime" | "childStart" | "childEnd" | "done" | "afterUpdate"

Parameters ​

type ​

Event

sub ​

Listener<UpdateLayerType<Event, Animating>>

options? ​

SignalOption

Returns ​

unsubscribe

Type Parameters ​

Animating ​

Animating extends UnknownAnimatable