var bool = WinJS.UI.isAnimationEnabled();
This method has no parameters.
Returns true if animations will be performed; otherwise false.
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 Animation Library's internal "enable" count, incremented and decremented by calls to enableAnimations and disableAnimations.
- The system accessibility setting, which can be retrieved through the Windows.UI.ViewManagement.UISettings.animationsEnabled property.
- Whether the app is running in the web context, and so doesn't have access to the Windows Runtime and the Windows.UI.ViewManagement.UISettings.animationsEnabled property. In this case, that property is assumed to be true.
The "enable" count and the system accessibility setting value are added together. If the value is 1 or greater, animations are performed.
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.
|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:
- 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.
- If an app without access to the Windows Runtime executes an animation from the Animations Library, that animation is performed.
- 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.
- 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.
- 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.
- 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.
Minimum WinJS version