Compartir a través de


WinJS.UI.isAnimationEnabled function

Determines whether the Animations Library and ListView animations will be performed if called.

Syntax

var bool = WinJS.UI.isAnimationEnabled();

Parameters

This method has no parameters.

Return value

Type: Bool

Returns true if animations will be performed; otherwise false.

Remarks

This function gives apps the information they need to keep their custom animation behavior in sync with the system accessibility setting. (The system accessibility setting is the "Turn off all unneccesary animations (when possible)" option found in the Ease of Access Center in Control Panel, and can be retrieved through the Windows.UI.ViewManagement.UISettings.animationsEnabled property.) For instance, an app running in the web context, which does not have access to the Windows Runtime, can determine whether it should disable its custom animations to match the system accessibility setting.

There are three elements involved in determining the return value for isAnimationEnabled:

The "enable" count and the system accessibility setting value are added together. If the value is 1 or greater, animations are performed.

Examples

The following table shows how the different factors combine to affect the return value of this function

Note  All apps running in the web context use a system accessibility setting of "true (1)" in this table, regardless of the actual system setting.

 

Enable count UISettings.animationsEnabled Total isAnimationEnabled Effect
0 true (1) 1 true Animations performed
0 false (0) 0 false Animations not performed
1 true (1) 2 true Animations performed
1 false (0) 1 true Animations performed
-1 true (1) 0 false Animations not performed
-1 false (0) -1 false Animations not performed

 

The settings interactions discussed above provide the following usage patterns:

  1. If an app with access to the Windows Runtime executes an animation from the Animations Library, that animation is performed based on the system accessibility setting.
  2. If an app without access to the Windows Runtime executes an animation from the Animations Library, that animation is performed.
  3. If an app calls enableAnimations once, then the Animations Library performs its animations, regardless of the system accessibility setting. The effect of calling enableAnimations once can be reversed by calling disableAnimations once. An app can bracket a call to the Animations Library inside calls to enableAnimations and disableAnimations to force a single animation to be performed.
  4. If an app calls disableAnimations once, then the Animations Library does not perform animations, regardless of the system accessibility setting. The effect of the call to disableAnimations can be reversed by calling enableAnimations once. An app can bracket a call to the Animations Library inside calls to disableAnimations and enableAnimations to suppress animations when that block of code is executed.
  5. An app can force animations to be performed by calling enableAnimations once and never calling disableAnimations. From that point onward, the Animation Library performs animations regardless of the system accessibility setting.
  6. An app can force animations to be disabled by calling disableAnimations once and never calling enableAnimations. From that point onward, the Animation Library performs animations regardless of the system accessibility setting.

While an app running in the web context does not have access to Windows Runtime and therefore assumes that animations are enabled, a multi-context app can have a helper object running in the local context which can query the system accessibility setting and instruct the web context app to call enableAnimations or disableAnimations accordingly.

Requirements

Minimum WinJS version

WinJS 3.0

Namespace

WinJS.UI

See also

enableAnimations

disableAnimations

HTML animation library sample

HTML ListView essentials sample