Animation class
Animations are used to animate GraphObject and Diagram properties.
This class is useful for creating manual animations. If you wish to animate particular properties on a GraphObject every time their value changes, you may want to use AnimationTriggers instead, which automatically create and start Animations.
The AnimationManager#defaultAnimation is an instance of this class, and carries out the default animations in GoJS: Model load, layout, expand and collapse, and so on. See the Introduction Page on Animations for more detail on the different kinds of animations.
Manual animations are set up by creating an instance of this class, and calling #add at least once, then calling #start. The method #add specifies which objects and which animation effects/properties to animate, plus start and end values for the property. As objects are added to an Animation, the Animation infers which Diagram and AnimationManager is relevant.
Animations are started by calling #start, and stopped when the #duration is reached, or when #stop is called,
or stopped when AnimationManager#stopAnimation is called with true
as its argument.
Animations can continue indefinitely if #runCount is set to Infinity
.
Animations can act upon temporary copies of an object that will get destroyed by calling #addTemporaryPart.
This is useful when crafting cosmetic animations of parts that are about to be deleted:
Since the part will no longer exist, you can instead animate a temporary part disappearing.
A simple example usage is this:
var node = myDiagram.nodes.first();
var shape = part.findObject("SHAPE"); // assumes this Node contains a go.Shape with .name = "SHAPE"
var animation = new go.Animation();
// Animate this Node from its current position to (400, 500)
animation.add(node, "position", node.position, new go.Point(400, 500));
// Animate the fill of the Shape within the Node, from its current color to blue
animation.add(shape, "fill", shape.fill, "blue");
// Both of these effects will animate simultaneously when start() is called:
animation.start();
See the Introduction Page on Animations and the Custom Animations sample for more example usage of the Animation class.
Unlike the AnimationManager#defaultAnimation, Animations can be started any time, and do not stop automatically when a new transaction begins.
- Available extensions
- Annotations
-
- @JS()
- @staticInterop
Constructors
- Animation([dynamic init])
-
factory
Properties
- duration ↔ num
-
Available on Animation, provided by the Animation$Typings extension
Gets or sets the duration for animations, in milliseconds.getter/setter pair - easing ↔ EasingFunction
-
Available on Animation, provided by the Animation$Typings extension
Gets or sets the easing function this Animation will use to modify default properties.getter/setter pair - finished ↔ void Function(Animation)?
-
Available on Animation, provided by the Animation$Typings extension
Gets or sets the function to execute when the user Animation finishes.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- isAnimating ↔ bool
-
Available on Animation, provided by the Animation$Typings extension
This read-only property is true when the Animation is currently running.getter/setter pair - isViewportUnconstrained ↔ bool
-
Available on Animation, provided by the Animation$Typings extension
Gets or sets whether this Animation should allow an unconstrained viewport during the runtime of the animation. This temporarily sets the Diagram#scrollMode to Diagram.InfiniteScroll, and restores the value at the end of the animation. This is done so that animating objects can move out of the viewport temporarily during the animation and not trigger scrollbars.getter/setter pair - reversible ↔ bool
-
Available on Animation, provided by the Animation$Typings extension
Gets or sets whether this Animation will repeat its animation in reverse at the end of the duration. Default false.getter/setter pair - runCount ↔ num
-
Available on Animation, provided by the Animation$Typings extension
Gets or sets whether this Animation should be repeat, and how many times. The default is 1, which means the animation does not repeat.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
Object obj, String effectName, [dynamic startValue, dynamic endValue, bool? cosmetic]) → Animation -
Available on Animation, provided by the Animation$Typings extension
Add an object (GraphObject or Diagram) and effect name, with specified start and end values, to this Animation. -
addTemporaryPart(
Part part, Diagram diagram) → Animation -
Available on Animation, provided by the Animation$Typings extension
Add a temporary Part to this animation. This part will be added to the Diagram when the animation is started, and removed from the Diagram when the animation completes. This is intended to be used with #add, to animate properties of this Part or its elements. -
advanceTo(
num duration, [bool? resume]) → void -
Available on Animation, provided by the Animation$Typings extension
@expose (undocumented) Debug only. -
getTemporaryState(
Object obj) → Object -
Available on Animation, provided by the Animation$Typings extension
Gets the ObjectData associated with this GraphObject or Diagram. If no state exists, this creates and returns a new ObjectData. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → Animation -
Available on Animation, provided by the Animation$Typings extension
Start this animation. -
stop(
) → Animation -
Available on Animation, provided by the Animation$Typings extension
Stops a running Animation and updates the animating objects to their final state. -
suspend(
) → void -
Available on Animation, provided by the Animation$Typings extension
@expose (undocumented) Debug only. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- easeInExpo ↔ EasingFunction
-
Built-in static function for computing interpolated values. Can be used as a value for Animation#easing.
getter/setter pair
- easeInOutQuad ↔ EasingFunction
-
Built-in static function for computing interpolated values. Can be used as a value for Animation#easing.
This is the default value for Animation#easing.
getter/setter pair
- easeInQuad ↔ EasingFunction
-
Built-in static function for computing interpolated values. Can be used as a value for Animation#easing.
getter/setter pair
- easeLinear ↔ EasingFunction
-
Built-in static function for computing interpolated values. Can be used as a value for Animation#easing.
getter/setter pair
- easeOutExpo ↔ EasingFunction
-
Built-in static function for computing interpolated values. Can be used as a value for Animation#easing.
getter/setter pair
- easeOutQuad ↔ EasingFunction
-
Built-in static function for computing interpolated values. Can be used as a value for Animation#easing.
getter/setter pair