Skip to content
import ViewAnimation from "@arcgis/core/views/ViewAnimation.js";
Inheritance:
ViewAnimationAccessor
Since
ArcGIS Maps SDK for JavaScript 4.0

Contains a state property used for checking the state of the animation. The view animation is resolved when the animation has finished and is rejected if it is stopped.

reactiveUtils.when(() => view.animation, function(animation) {
console.log(animation.state); // prints out "running"
animation.when(function(animation) {
console.log(animation.state); // prints out "finished"
})
.catch(function(animation) {
console.log(animation.state); // prints out "stopped"
});
});

Alternatively the state property can be watched for changes:

let animation = view.goTo(target, { speedFactor: 0.1 });
reactiveUtils.watch(
() => animation.state,
(state) => {
switch (state) {
case "finished":
console.log("Animation finished.");
break;
case "stopped":
console.log("Animation stopped.");
break;
}
}
);
See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

state

readonly Property
Type
ViewAnimationStateType

The state of the animation.

The animation terminates when the state is either finished or stopped and cannot transition again to running. The finished state indicates the animation has successfully ended, while the stopped state indicates that the animation was interrupted before it reached its final target.

Default value
"running"

target

Property
Type
Viewpoint | Promise<Viewpoint> | null | undefined

The target of the animation.

Methods

MethodSignatureClass
finish(): void
isFulfilled
inherited
isFulfilled(): boolean
isRejected
inherited
isRejected(): boolean
isResolved
inherited
isResolved(): boolean
stop(): void
when
inherited
when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>

finish

Method
Signature
finish (): void

Finishes the view animation by immediately going to the target and sets the state of the animation to finished.

Returns
void

isFulfilled

inherited Method
Signature
isFulfilled (): boolean
Inherited from: EsriPromiseMixin

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled, true will be returned.

Returns
boolean

Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).

isRejected

inherited Method
Signature
isRejected (): boolean
Inherited from: EsriPromiseMixin

isRejected() may be used to verify if creating an instance of the class is rejected. If it is rejected, true will be returned.

Returns
boolean

Indicates whether creating an instance of the class has been rejected.

isResolved

inherited Method
Signature
isResolved (): boolean
Inherited from: EsriPromiseMixin

isResolved() may be used to verify if creating an instance of the class is resolved. If it is resolved, true will be returned.

Returns
boolean

Indicates whether creating an instance of the class has been resolved.

stop

Method
Signature
stop (): void

Stops the view animation at its current state and sets the state of the animation to stopped.

Returns
void

when

inherited Method
Signature
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
Type parameters
<TResult1 = this, TResult2 = never>
Inherited from: EsriPromiseMixin
Since
ArcGIS Maps SDK for JavaScript 4.6

when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function. The onFulfilled executes when the instance of the class loads. The onRejected executes if the instance of the class fails to load.

Parameters
ParameterTypeDescriptionRequired
onFulfilled

The function to call when the promise resolves.

onRejected

The function to execute when the promise fails.

Returns
Promise<TResult1 | TResult2>

Returns a new promise for the result of onFulfilled that may be used to chain additional functions.

Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same way
let view = new MapView();
view.when(function(){
// This function will execute once the promise is resolved
}, function(error){
// This function will execute if the promise is rejected due to an error
});