Skip to content

aninest root / AnimatableEvents / removeLocalListener

removeLocalListener()

ts
function removeLocalListener<Animating, Event>(
   anim, 
   type, 
   listener): void

Removes a listener from the animation

Type Parameters

Animating extends RecursiveAnimatable<unknown>

Event extends AnimatableEvents

Parameters

anim: Animation<Animating>

The animation object

type: Event

See AnimatableEvents

listener: Event extends | "beforeStart" | "immutableStart" | "start" | "end" | "interrupt" | "beforeEnd" ? Listener<Partial<LocalAnimatable<Animating>>> : Listener<undefined>

The listener function to remove

Returns

void

See

addLocalListener to add a listener to an animation

Example

ts
// setup
const anim = createAnimation({ a: newVec2(0, 0), b: newVec(0, 0) }, getLinearInterp(1))
const listener = state => console.log("started", state)
addLocalListener(anim, "start", listener)

modifyTo(anim, {a: {x: 1}}) // will trigger the listener

removeLocalListener(anim, "start", listener)
modifyTo(anim, {a: {x: 0}}) // will not trigger the listener

Deprecated

Instead use the return value of {@link addLocalListener} or the AbortSignal passed into {@link addLocalListener} with the options' signal field.

Defined in

Animate/AnimatableEvents.ts:143