Skip to content

Animation

Type class

Animation can be used to transition certain properties on an object that implements IAnimatable interface.

More info: IAnimationEvents for a list of available events

Sources

Animation can be used (imported) via one of the following packages.

/**
* Import from: "core.ts"
* Use like: am4core.Animation
*/
import * as am4core from "@amcharts/amcharts4/core";

Inheritance

Animation extends BaseObjectEvents.

Animation is not extended by any other symbol.

Properties

animationOptions

Type IAnimationOptions[]

An array of animation option objects. Each animation object represent one property. Animation can animate any number of properties simultaneously.

delayed

Type boolean

Returns true if this animation is delayed.

duration

Type numberDefault 0

Duration of the animation in milliseconds.

easing

Type (value: number) => numberDefault $ease.linear

Easing function to use.

More info: Ease

object

Type IAnimatable

An animation target object. Animation will update properties of this object.

progress

Type numberDefault 0

Contains progress of the current animation: 0 (start) to 1 (end).

5 inherited items
clonedFrom

Type $type.Optional <this>Inherited from BaseObject

Reference to the original object this object was cloned from. We need to keep this so we can disassociate it from source object when this object is disposed.

config

Type objectInherited from BaseObject

Use this property to set JSON-based config. When set, triggers processing routine, which will go through all properties, and try to apply values, create instances, etc.

Use this with caution, as it is a time-consuming process. It's used for initialchart setup only, not routine operations.

events

Type EventDispatcher <AMEvent <this, IBaseObjectEvents>>Inherited from BaseObjectEvents

An EventDispatcher instance

id

Type $type.Optional <string>Inherited from BaseObject

Sets the user-defined id of the element.

uid

Type stringInherited from BaseObject

Returns object's internal unique ID.

Methods

constructor(object: IAnimatable,
animationOptions: IAnimationOptions[] | IAnimationOptions,
duration: number,
easing?: (value: number) => number
)

Returns Animation

Constructor

delay(delay: number)

Returns Animation

Delays animation start by X milliseconds.

dispose()

Returns void

Disposes this object, clears up after itself.

end()

Returns Animation

Jumps to animation end. If animation is set to loop, this will start another round of animation from start.

isFinished()

Returns boolean

Returns indicator if this animation is finished or not

kill()

Returns void

Stops animation immediately leaving properties in their current values.

loop(count?: number)

Returns Animation

Sets loop count for the animation. If parameter is not a valid number the animation will keep on looping indefinitely.

pause()

Returns Animation

Pauses animation.

resume()

Returns Animation

Resumes paused animation.

setProgress(progress: number)

Returns void

Sets current progress and updates object's numeric and color values.

start()

Returns Animation

Starts animation.

stop(skipEvent?: boolean)

Returns Animation

Stops animation.

When animation is stopped, the properties of the target object will remain where they were at the moment when stop() was called.

6 inherited items
clone(cloneId?: string)

Returns thisInherited from BaseObject

Makes a copy of this object and returns the clone. Try to avoid cloning complex objects like chart, create new instances if you need them.

copyFrom(source: this)

Returns voidInherited from BaseObjectEvents

Copies all parameters from another Sprite.

dispatch(eventType: Key,
data?: any
)

Returns voidInherited from BaseObjectEvents

Dispatches an event using own event dispatcher. Will automatically populate event data object with event type and target (this element).

It also checks if there are any handlers registered for this sepecific event.

dispatchImmediately(eventType: Key,
data?: any
)

Returns voidInherited from BaseObjectEvents

Works like dispatch, except event is triggered immediately, without waiting for the next frame cycle.

getCurrentThemes()

Returns ITheme[]Inherited from BaseObject

Returns a list of themes that should be applied to this element. It could either be a list of themes set explicitly on this element, or system-wide.

isDisposed()

Returns booleanInherited from BaseObject

Returns if this object has been already been disposed.

Events

animationended

Param { type: "animationended", target: Animation, progress: number }

Invoked when animation finishes playing.

animationprogress

Param { type: "animationprogress", target: Animation, progress: number }

Invoked when animation makes progress.

animationstarted

Param { type: "animationstarted", target: Animation, progress: number }

Invoked when animation starts playing.

animationstopped

Param { type: "animationstopped", target: Animation, progress: number }

Invoked when animation is stopped by some other process, before it had a chance to finish.