add reduce motion for ios

limit reduce motion check to iOS 8+
This commit is contained in:
Daniel Wilson
2016-03-07 09:57:56 -06:00
committed by Michael Jordan
parent e989af802c
commit dbfde0134d
5 changed files with 95 additions and 2 deletions
+55
View File
@@ -31,6 +31,7 @@ The `MobileAccessibility` object, exposed by `window.MobileAccessibility`, provi
- MobileAccessibility.isGuidedAccessEnabled
- MobileAccessibility.isInvertColorsEnabled
- MobileAccessibility.isMonoAudioEnabled
- MobileAccessibility.isReduceMotionEnabled
- MobileAccessibility.isTouchExplorationEnabled
- MobileAccessibility.getTextZoom
- MobileAccessibility.setTextZoom
@@ -284,6 +285,35 @@ Makes an asynchronous call to native `MobileAccessibility` to determine if mono
- iOS
----------------------------------------------------
#### MobileAccessibility.isReduceMotionEnabled(callback)
An iOS-specific proxy for the `MobileAccessibility.UIAccessibilityIsReduceMotionEnabled` method.
##### Parameters
- __callback__ (Function) A callback method to receive the boolean result asynchronously from the native `MobileAccessibility` plugin.
##### Usage
```javascript
function isReduceMotionEnabledCallback(boolean) {
if (boolean) {
console.log("Reduce Motion: ON");
// Do something to improve the behavior of the application when reduce motion is enabled.
} else {
console.log("Reduce Motion: OFF");
}
}
MobileAccessibility.isReduceMotionEnabled(isReduceMotionEnabledCallback);
```
##### Supported Platforms
- iOS
------------------------------------------------------------
#### MobileAccessibility.isTouchExplorationEnabled(callback)
@@ -503,6 +533,7 @@ The following event constants are for `window` events, to which an application c
- MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED
- MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED
- MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED
- MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED
- MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED
----------------------------------------------------------------------------------------------
@@ -625,6 +656,30 @@ If a screen reader is active, `info.isMonoAudioEnabled` will equal `true`.
window.addEventListener(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED, onMonoAudioStatusChanged, false);
```
----------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED (reducemotionstatuschanged)
The event fires when Reduce Motion has been enabled on an iOS device.
The event returns an object, `info`, with the current status of accessibility features on the device.
If a screen reader is active, `info.isReduceMotionEnabled` will equal `true`.
```javascript
// Define a persistent callback method to handle the event
function onReduceMotionStatusChanged(info) {
if (info && typeof info.isReduceMotionEnabled !== "undefined") {
if (info.isReduceMotionEnabled) {
console.log("Reduce Motion: ON");
// Do something to improve the behavior of the application while Reduce Motion is enabled.
} else {
console.log("Reduce Motion: OFF");
}
}
}
// Register the callback method to handle the event
window.addEventListener(MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED, onMReduceMotionStatusChanged, false);
```
------------------------------------------------------------------------------------------------------
#### MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED (touchexplorationstatuschanged)