Skip to main content

Function: overrideAnimate()

overrideAnimate<M>(mobjectClass, methodName, animationFactory): void

Defined in: src/animation/AnimationUtilities.ts:67

overrideAnimate - Register a custom .animate behavior for a method, by class.

TS-idiomatic form of CE's @override_animate(method) decorator. CE decorates a method so that mob.animate.method() plays a custom animation instead of interpolating the method's effect. A decorator needs a target, and this repo does not use TypeScript decorators, so the override is registered against the mobject class and method name. AnimateProxy.begin consults this registry (via getAnimationOverride) and uses the factory when exactly that method is recorded, so wiring the hook is not needed.

The class key matches the lookup in AnimateProxy: the static className (survives minification) when present, otherwise mobjectClass.name.

Type Parameters​

M​

M extends Mobject

Parameters​

mobjectClass​

(...args) => M

The mobject class the override applies to.

methodName​

string

The method whose .animate behavior is overridden.

animationFactory​

AnimationOverrideFunc

Builds the animation played for mob.animate[methodName]().

Returns​

void

Example​

overrideAnimate(MyMobject, 'clearContent', (mob, args) => new Uncreate(mob, args));
myMobject.animate.clearContent(); // plays Uncreate instead of a Transform