@samitouri / QOS-React-2 / commits / cc56629620

Fix transition end detection for Android

Some Android versions have the "transition" and "animation" properties set on element style objects despite not supporting un-prefxied animations and transitions. This change adds an additional sanity check to make sure the correct event handlers are added for transition groups.

Marcin Szczepanski committed Mar 20, 2014 at 15:11 UTC cc56629620bf6929f7bb7d375f3738527eb26031
1 file changed +19
src/addons/transitions/ReactTransitionEvents.js
+19
@@ -20,6 +20,11 @@
20
21 var ExecutionEnvironment = require('ExecutionEnvironment');
22
23 +/**
24 + * EVENT_NAME_MAP is used to determine which event fired when a
25 + * transition/animation ends, based on the style property used to
26 + * define that event.
27 + */
28 var EVENT_NAME_MAP = {
29 transitionend: {
30 'transition': 'transitionend',
@@ -43,6 +48,20 @@ var endEvents = [];
48 function detectEvents() {
49 var testEl = document.createElement('div');
50 var style = testEl.style;
51 +
52 + // On some platforms, in particular some releases of Android 4.x,
53 + // the un-prefixed "animation" and "transition" properties are defined on the
54 + // style object but the events that fire will still be prefixed, so we need
55 + // to check if the un-prefixed events are useable, and if not remove them
56 + // from the map
57 + if (!('AnimationEvent' in window)) {
58 + delete EVENT_NAME_MAP.animationend.animation;
59 + }
60 +
61 + if (!('TransitionEvent' in window)) {
62 + delete EVENT_NAME_MAP.transitionend.transition;
63 + }
64 +
65 for (var baseEventName in EVENT_NAME_MAP) {
66 var baseEvents = EVENT_NAME_MAP[baseEventName];
67 for (var styleName in baseEvents) {