@angular/animations 6.0.3 → 6.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/browser/browser.metadata.json +1 -1
  2. package/browser/src/dsl/animation_transition_factory.d.ts +1 -1
  3. package/browser/src/render/animation_engine_next.d.ts +2 -1
  4. package/browser/src/render/shared.d.ts +2 -0
  5. package/browser/src/render/timeline_animation_engine.d.ts +2 -1
  6. package/browser/src/render/transition_animation_engine.d.ts +3 -3
  7. package/browser/testing.d.ts +0 -5
  8. package/browser/testing.metadata.json +1 -1
  9. package/browser.d.ts +0 -5
  10. package/browser.metadata.json +1 -1
  11. package/bundles/animations-browser-testing.umd.js +28 -10
  12. package/bundles/animations-browser-testing.umd.js.map +1 -1
  13. package/bundles/animations-browser-testing.umd.min.js +16 -2
  14. package/bundles/animations-browser-testing.umd.min.js.map +1 -1
  15. package/bundles/animations-browser.umd.js +200 -83
  16. package/bundles/animations-browser.umd.js.map +1 -1
  17. package/bundles/animations-browser.umd.min.js +55 -6
  18. package/bundles/animations-browser.umd.min.js.map +1 -1
  19. package/bundles/animations.umd.js +470 -577
  20. package/bundles/animations.umd.js.map +1 -1
  21. package/bundles/animations.umd.min.js +9 -2
  22. package/bundles/animations.umd.min.js.map +1 -1
  23. package/esm2015/animations.externs.js +1 -1
  24. package/esm2015/browser/browser.externs.js +3 -3
  25. package/esm2015/browser/src/dsl/animation_transition_factory.js +4 -3
  26. package/esm2015/browser/src/render/animation_driver.js +1 -12
  27. package/esm2015/browser/src/render/animation_engine_next.js +8 -4
  28. package/esm2015/browser/src/render/shared.js +18 -3
  29. package/esm2015/browser/src/render/timeline_animation_engine.js +6 -2
  30. package/esm2015/browser/src/render/transition_animation_engine.js +23 -19
  31. package/esm2015/browser/src/render/web_animations/web_animations_driver.js +3 -3
  32. package/esm2015/browser/src/util.js +57 -1
  33. package/esm2015/src/animation_metadata.js +626 -659
  34. package/esm2015/src/version.js +1 -1
  35. package/esm5/browser/index.js +5 -1
  36. package/esm5/browser/public_api.js +6 -1
  37. package/esm5/browser/src/browser.js +6 -1
  38. package/esm5/browser/src/dsl/animation.js +1 -1
  39. package/esm5/browser/src/dsl/animation_ast_builder.js +11 -4
  40. package/esm5/browser/src/dsl/animation_timeline_builder.js +27 -21
  41. package/esm5/browser/src/dsl/animation_timeline_instruction.js +1 -1
  42. package/esm5/browser/src/dsl/animation_transition_expr.js +1 -1
  43. package/esm5/browser/src/dsl/animation_transition_factory.js +3 -3
  44. package/esm5/browser/src/dsl/animation_transition_instruction.js +1 -1
  45. package/esm5/browser/src/dsl/animation_trigger.js +2 -8
  46. package/esm5/browser/src/dsl/element_instruction_map.js +1 -1
  47. package/esm5/browser/src/dsl/style_normalization/animation_style_normalizer.js +3 -15
  48. package/esm5/browser/src/dsl/style_normalization/web_animations_style_normalizer.js +8 -1
  49. package/esm5/browser/src/private_export.js +8 -1
  50. package/esm5/browser/src/render/animation_driver.js +8 -3
  51. package/esm5/browser/src/render/animation_engine_next.js +5 -4
  52. package/esm5/browser/src/render/css_keyframes/css_keyframes_driver.js +1 -1
  53. package/esm5/browser/src/render/css_keyframes/css_keyframes_player.js +2 -4
  54. package/esm5/browser/src/render/css_keyframes/direct_style_player.js +8 -1
  55. package/esm5/browser/src/render/css_keyframes/element_animation_style_handler.js +1 -1
  56. package/esm5/browser/src/render/shared.js +19 -3
  57. package/esm5/browser/src/render/timeline_animation_engine.js +10 -2
  58. package/esm5/browser/src/render/transition_animation_engine.js +36 -39
  59. package/esm5/browser/src/render/web_animations/dom_animation.js +1 -1
  60. package/esm5/browser/src/render/web_animations/web_animations_driver.js +3 -3
  61. package/esm5/browser/src/render/web_animations/web_animations_player.js +3 -7
  62. package/esm5/browser/src/util.js +51 -3
  63. package/esm5/browser/testing/index.js +5 -1
  64. package/esm5/browser/testing/public_api.js +6 -1
  65. package/esm5/browser/testing/src/mock_animation_driver.js +12 -17
  66. package/esm5/browser/testing/src/testing.js +8 -1
  67. package/esm5/index.js +5 -1
  68. package/esm5/public_api.js +6 -1
  69. package/esm5/src/animation_builder.js +3 -93
  70. package/esm5/src/animation_event.js +1 -1
  71. package/esm5/src/animation_metadata.js +439 -568
  72. package/esm5/src/animations.js +6 -1
  73. package/esm5/src/players/animation_group_player.js +2 -4
  74. package/esm5/src/players/animation_player.js +11 -14
  75. package/esm5/src/private_export.js +8 -1
  76. package/esm5/src/util.js +1 -1
  77. package/esm5/src/version.js +3 -23
  78. package/fesm2015/animations.js +446 -631
  79. package/fesm2015/animations.js.map +1 -1
  80. package/fesm2015/browser/testing.js +1 -1
  81. package/fesm2015/browser/testing.js.map +1 -1
  82. package/fesm2015/browser.js +104 -29
  83. package/fesm2015/browser.js.map +1 -1
  84. package/fesm5/animations.js +470 -577
  85. package/fesm5/animations.js.map +1 -1
  86. package/fesm5/browser/testing.js +28 -10
  87. package/fesm5/browser/testing.js.map +1 -1
  88. package/fesm5/browser.js +200 -83
  89. package/fesm5/browser.js.map +1 -1
  90. package/package.json +3 -3
  91. package/src/animation_metadata.d.ts +673 -650
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v6.0.3
2
+ * @license Angular v6.0.7
3
3
  * (c) 2010-2018 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -92,6 +92,19 @@ function __spread() {
92
92
  return ar;
93
93
  }
94
94
 
95
+ /**
96
+ * @license
97
+ * Copyright Google Inc. All Rights Reserved.
98
+ *
99
+ * Use of this source code is governed by an MIT-style license that can be
100
+ * found in the LICENSE file at https://angular.io/license
101
+ */
102
+ function isBrowser() {
103
+ return (typeof window !== 'undefined' && typeof window.document !== 'undefined');
104
+ }
105
+ function isNode() {
106
+ return (typeof process !== 'undefined');
107
+ }
95
108
  function optimizeGroupPlayer(players) {
96
109
  switch (players.length) {
97
110
  case 0:
@@ -202,10 +215,13 @@ var _matches = function (element, selector) {
202
215
  var _query = function (element, selector, multi) {
203
216
  return [];
204
217
  };
205
- if (typeof Element != 'undefined') {
218
+ // Define utility methods for browsers and platform-server(domino) where Element
219
+ // and utility methods exist.
220
+ var _isNode = isNode();
221
+ if (_isNode || typeof Element !== 'undefined') {
206
222
  // this is well supported in all browsers
207
223
  _contains = function (elm1, elm2) { return elm1.contains(elm2); };
208
- if (Element.prototype.matches) {
224
+ if (_isNode || Element.prototype.matches) {
209
225
  _matches = function (element, selector) { return element.matches(selector); };
210
226
  }
211
227
  else {
@@ -270,6 +286,13 @@ function hypenatePropsObject(object) {
270
286
  return newObj;
271
287
  }
272
288
 
289
+ /**
290
+ * @license
291
+ * Copyright Google Inc. All Rights Reserved.
292
+ *
293
+ * Use of this source code is governed by an MIT-style license that can be
294
+ * found in the LICENSE file at https://angular.io/license
295
+ */
273
296
  /**
274
297
  * @experimental
275
298
  */
@@ -294,8 +317,6 @@ var NoopAnimationDriver = /** @class */ (function () {
294
317
  NoopAnimationDriver.decorators = [
295
318
  { type: core.Injectable }
296
319
  ];
297
- /** @nocollapse */
298
- NoopAnimationDriver.ctorParameters = function () { return []; };
299
320
  return NoopAnimationDriver;
300
321
  }());
301
322
  /**
@@ -308,6 +329,13 @@ var AnimationDriver = /** @class */ (function () {
308
329
  return AnimationDriver;
309
330
  }());
310
331
 
332
+ /**
333
+ * @license
334
+ * Copyright Google Inc. All Rights Reserved.
335
+ *
336
+ * Use of this source code is governed by an MIT-style license that can be
337
+ * found in the LICENSE file at https://angular.io/license
338
+ */
311
339
  var ONE_SECOND = 1000;
312
340
  var SUBSTITUTION_EXPR_START = '{{';
313
341
  var SUBSTITUTION_EXPR_END = '}}';
@@ -331,8 +359,7 @@ function _convertTimeValueToMS(value, unit) {
331
359
  switch (unit) {
332
360
  case 's':
333
361
  return value * ONE_SECOND;
334
- default:
335
- // ms or something else
362
+ default:// ms or something else
336
363
  return value;
337
364
  }
338
365
  }
@@ -412,12 +439,46 @@ function copyStyles(styles, readPrototype, destination) {
412
439
  }
413
440
  return destination;
414
441
  }
442
+ function getStyleAttributeString(element, key, value) {
443
+ // Return the key-value pair string to be added to the style attribute for the
444
+ // given CSS style key.
445
+ if (value) {
446
+ return key + ':' + value + ';';
447
+ }
448
+ else {
449
+ return '';
450
+ }
451
+ }
452
+ function writeStyleAttribute(element) {
453
+ // Read the style property of the element and manually reflect it to the
454
+ // style attribute. This is needed because Domino on platform-server doesn't
455
+ // understand the full set of allowed CSS properties and doesn't reflect some
456
+ // of them automatically.
457
+ var styleAttrValue = '';
458
+ for (var i = 0; i < element.style.length; i++) {
459
+ var key = element.style.item(i);
460
+ styleAttrValue += getStyleAttributeString(element, key, element.style.getPropertyValue(key));
461
+ }
462
+ for (var key in element.style) {
463
+ // Skip internal Domino properties that don't need to be reflected.
464
+ if (!element.style.hasOwnProperty(key) || key.startsWith('_')) {
465
+ continue;
466
+ }
467
+ var dashKey = camelCaseToDashCase(key);
468
+ styleAttrValue += getStyleAttributeString(element, dashKey, element.style[key]);
469
+ }
470
+ element.setAttribute('style', styleAttrValue);
471
+ }
415
472
  function setStyles(element, styles) {
416
473
  if (element['style']) {
417
474
  Object.keys(styles).forEach(function (prop) {
418
475
  var camelProp = dashCaseToCamelCase(prop);
419
476
  element.style[camelProp] = styles[prop];
420
477
  });
478
+ // On the server set the 'style' attribute since it's not automatically reflected.
479
+ if (isNode()) {
480
+ writeStyleAttribute(element);
481
+ }
421
482
  }
422
483
  }
423
484
  function eraseStyles(element, styles) {
@@ -426,6 +487,10 @@ function eraseStyles(element, styles) {
426
487
  var camelProp = dashCaseToCamelCase(prop);
427
488
  element.style[camelProp] = '';
428
489
  });
490
+ // On the server set the 'style' attribute since it's not automatically reflected.
491
+ if (isNode()) {
492
+ writeStyleAttribute(element);
493
+ }
429
494
  }
430
495
  }
431
496
  function normalizeAnimationEntry(steps) {
@@ -494,6 +559,9 @@ function dashCaseToCamelCase(input) {
494
559
  return m[1].toUpperCase();
495
560
  });
496
561
  }
562
+ function camelCaseToDashCase(input) {
563
+ return input.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
564
+ }
497
565
  function allowPreviousPlayerStylesMerge(duration, delay) {
498
566
  return duration === 0 || delay === 0;
499
567
  }
@@ -637,6 +705,13 @@ function makeLambdaFromStates(lhs, rhs) {
637
705
  };
638
706
  }
639
707
 
708
+ /**
709
+ * @license
710
+ * Copyright Google Inc. All Rights Reserved.
711
+ *
712
+ * Use of this source code is governed by an MIT-style license that can be
713
+ * found in the LICENSE file at https://angular.io/license
714
+ */
640
715
  var SELF_TOKEN = ':self';
641
716
  var SELF_TOKEN_REGEX = new RegExp("s*" + SELF_TOKEN + "s*,?", 'g');
642
717
  /*
@@ -967,7 +1042,7 @@ var AnimationAstBuilderVisitor = /** @class */ (function () {
967
1042
  }
968
1043
  var limit = length - 1;
969
1044
  var currentTime = context.currentTime;
970
- var currentAnimateTimings = (context.currentAnimateTimings);
1045
+ var currentAnimateTimings = context.currentAnimateTimings;
971
1046
  var animateDuration = currentAnimateTimings.duration;
972
1047
  keyframes.forEach(function (kf, i) {
973
1048
  var offset = generatedOffset > 0 ? (i == limit ? 1 : (generatedOffset * i)) : offsets[i];
@@ -1002,7 +1077,7 @@ var AnimationAstBuilderVisitor = /** @class */ (function () {
1002
1077
  };
1003
1078
  };
1004
1079
  AnimationAstBuilderVisitor.prototype.visitQuery = function (metadata, context) {
1005
- var parentSelector = (context.currentQuerySelector);
1080
+ var parentSelector = context.currentQuerySelector;
1006
1081
  var options = (metadata.options || {});
1007
1082
  context.queryCount++;
1008
1083
  context.currentQuery = metadata;
@@ -1113,7 +1188,7 @@ function normalizeAnimationOptions(options) {
1113
1188
  if (options) {
1114
1189
  options = copyObj(options);
1115
1190
  if (options['params']) {
1116
- options['params'] = (normalizeParams(options['params']));
1191
+ options['params'] = normalizeParams(options['params']);
1117
1192
  }
1118
1193
  }
1119
1194
  else {
@@ -1166,6 +1241,13 @@ var ElementInstructionMap = /** @class */ (function () {
1166
1241
  return ElementInstructionMap;
1167
1242
  }());
1168
1243
 
1244
+ /**
1245
+ * @license
1246
+ * Copyright Google Inc. All Rights Reserved.
1247
+ *
1248
+ * Use of this source code is governed by an MIT-style license that can be
1249
+ * found in the LICENSE file at https://angular.io/license
1250
+ */
1169
1251
  var ONE_FRAME_IN_MILLISECONDS = 1;
1170
1252
  var ENTER_TOKEN = ':enter';
1171
1253
  var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g');
@@ -1415,7 +1497,7 @@ var AnimationTimelineBuilderVisitor = /** @class */ (function () {
1415
1497
  };
1416
1498
  AnimationTimelineBuilderVisitor.prototype.visitStyle = function (ast, context) {
1417
1499
  var timeline = context.currentTimeline;
1418
- var timings = (context.currentAnimateTimings);
1500
+ var timings = context.currentAnimateTimings;
1419
1501
  // this is a special case for when a style() call
1420
1502
  // directly follows an animate() call (but not inside of an animate() call)
1421
1503
  if (!timings && timeline.getCurrentStyleProperties().length) {
@@ -1431,7 +1513,7 @@ var AnimationTimelineBuilderVisitor = /** @class */ (function () {
1431
1513
  context.previousNode = ast;
1432
1514
  };
1433
1515
  AnimationTimelineBuilderVisitor.prototype.visitKeyframes = function (ast, context) {
1434
- var currentAnimateTimings = (context.currentAnimateTimings);
1516
+ var currentAnimateTimings = context.currentAnimateTimings;
1435
1517
  var startTime = (context.currentTimeline).duration;
1436
1518
  var duration = currentAnimateTimings.duration;
1437
1519
  var innerContext = context.createSubContext();
@@ -1494,7 +1576,7 @@ var AnimationTimelineBuilderVisitor = /** @class */ (function () {
1494
1576
  context.previousNode = ast;
1495
1577
  };
1496
1578
  AnimationTimelineBuilderVisitor.prototype.visitStagger = function (ast, context) {
1497
- var parentContext = (context.parentContext);
1579
+ var parentContext = context.parentContext;
1498
1580
  var tl = context.currentTimeline;
1499
1581
  var timings = ast.timings;
1500
1582
  var duration = Math.abs(timings.duration);
@@ -1566,7 +1648,7 @@ var AnimationTimelineContext = /** @class */ (function () {
1566
1648
  }
1567
1649
  var newParams = newOptions.params;
1568
1650
  if (newParams) {
1569
- var paramsToUpdate_1 = (optionsToUpdate.params);
1651
+ var paramsToUpdate_1 = optionsToUpdate.params;
1570
1652
  if (!paramsToUpdate_1) {
1571
1653
  paramsToUpdate_1 = this.options.params = {};
1572
1654
  }
@@ -1633,7 +1715,6 @@ var AnimationTimelineContext = /** @class */ (function () {
1633
1715
  results.push(this.element);
1634
1716
  }
1635
1717
  if (selector.length > 0) {
1636
- // if :self is only used then the selector is empty
1637
1718
  selector = selector.replace(ENTER_TOKEN_REGEX, '.' + this._enterClassName);
1638
1719
  selector = selector.replace(LEAVE_TOKEN_REGEX, '.' + this._leaveClassName);
1639
1720
  var multi = limit != 1;
@@ -1669,7 +1750,7 @@ var TimelineBuilder = /** @class */ (function () {
1669
1750
  this._elementTimelineStylesLookup = new Map();
1670
1751
  }
1671
1752
  this._localTimelineStyles = Object.create(this._backFill, {});
1672
- this._globalTimelineStyles = (this._elementTimelineStylesLookup.get(element));
1753
+ this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element);
1673
1754
  if (!this._globalTimelineStyles) {
1674
1755
  this._globalTimelineStyles = this._localTimelineStyles;
1675
1756
  this._elementTimelineStylesLookup.set(element, this._localTimelineStyles);
@@ -1716,7 +1797,7 @@ var TimelineBuilder = /** @class */ (function () {
1716
1797
  if (this._currentKeyframe) {
1717
1798
  this._previousKeyframe = this._currentKeyframe;
1718
1799
  }
1719
- this._currentKeyframe = (this._keyframes.get(this.duration));
1800
+ this._currentKeyframe = this._keyframes.get(this.duration);
1720
1801
  if (!this._currentKeyframe) {
1721
1802
  this._currentKeyframe = Object.create(this._backFill, {});
1722
1803
  this._keyframes.set(this.duration, this._currentKeyframe);
@@ -1885,19 +1966,19 @@ var SubTimelineBuilder = /** @class */ (function (_super) {
1885
1966
  oldFirstKeyframe['offset'] = roundOffset(startingGap);
1886
1967
  newKeyframes.push(oldFirstKeyframe);
1887
1968
  /*
1888
- When the keyframe is stretched then it means that the delay before the animation
1889
- starts is gone. Instead the first keyframe is placed at the start of the animation
1890
- and it is then copied to where it starts when the original delay is over. This basically
1891
- means nothing animates during that delay, but the styles are still renderered. For this
1892
- to work the original offset values that exist in the original keyframes must be "warped"
1893
- so that they can take the new keyframe + delay into account.
1894
-
1895
- delay=1000, duration=1000, keyframes = 0 .5 1
1896
-
1897
- turns into
1898
-
1899
- delay=0, duration=2000, keyframes = 0 .33 .66 1
1900
- */
1969
+ When the keyframe is stretched then it means that the delay before the animation
1970
+ starts is gone. Instead the first keyframe is placed at the start of the animation
1971
+ and it is then copied to where it starts when the original delay is over. This basically
1972
+ means nothing animates during that delay, but the styles are still renderered. For this
1973
+ to work the original offset values that exist in the original keyframes must be "warped"
1974
+ so that they can take the new keyframe + delay into account.
1975
+
1976
+ delay=1000, duration=1000, keyframes = 0 .5 1
1977
+
1978
+ turns into
1979
+
1980
+ delay=0, duration=2000, keyframes = 0 .33 .66 1
1981
+ */
1901
1982
  // offsets between 1 ... n -1 are all warped by the keyframe stretch
1902
1983
  var limit = keyframes.length - 1;
1903
1984
  for (var i = 1; i <= limit; i++) {
@@ -1993,6 +2074,13 @@ var NoopAnimationStyleNormalizer = /** @class */ (function () {
1993
2074
  return NoopAnimationStyleNormalizer;
1994
2075
  }());
1995
2076
 
2077
+ /**
2078
+ * @license
2079
+ * Copyright Google Inc. All Rights Reserved.
2080
+ *
2081
+ * Use of this source code is governed by an MIT-style license that can be
2082
+ * found in the LICENSE file at https://angular.io/license
2083
+ */
1996
2084
  var WebAnimationsStyleNormalizer = /** @class */ (function (_super) {
1997
2085
  __extends(WebAnimationsStyleNormalizer, _super);
1998
2086
  function WebAnimationsStyleNormalizer() {
@@ -2062,7 +2150,7 @@ var AnimationTransitionFactory = /** @class */ (function () {
2062
2150
  var backupStyles = backupStateStyler ? backupStateStyler.buildStyles(params, errors) : {};
2063
2151
  return stateStyler ? stateStyler.buildStyles(params, errors) : backupStyles;
2064
2152
  };
2065
- AnimationTransitionFactory.prototype.build = function (driver, element, currentState, nextState, enterClassName, leaveClassName, currentOptions, nextOptions, subInstructions) {
2153
+ AnimationTransitionFactory.prototype.build = function (driver, element, currentState, nextState, enterClassName, leaveClassName, currentOptions, nextOptions, subInstructions, skipAstBuild) {
2066
2154
  var errors = [];
2067
2155
  var transitionAnimationParams = this.ast.options && this.ast.options.params || EMPTY_OBJECT;
2068
2156
  var currentAnimationParams = currentOptions && currentOptions.params || EMPTY_OBJECT;
@@ -2074,7 +2162,7 @@ var AnimationTransitionFactory = /** @class */ (function () {
2074
2162
  var postStyleMap = new Map();
2075
2163
  var isRemoval = nextState === 'void';
2076
2164
  var animationOptions = { params: __assign({}, transitionAnimationParams, nextAnimationParams) };
2077
- var timelines = buildAnimationTimelines(driver, element, this.ast.animation, enterClassName, leaveClassName, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors);
2165
+ var timelines = skipAstBuild ? [] : buildAnimationTimelines(driver, element, this.ast.animation, enterClassName, leaveClassName, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors);
2078
2166
  var totalTime = 0;
2079
2167
  timelines.forEach(function (tl) { totalTime = Math.max(tl.duration + tl.delay, totalTime); });
2080
2168
  if (errors.length) {
@@ -2194,9 +2282,17 @@ function balanceProperties(obj, key1, key2) {
2194
2282
  }
2195
2283
  }
2196
2284
 
2285
+ /**
2286
+ * @license
2287
+ * Copyright Google Inc. All Rights Reserved.
2288
+ *
2289
+ * Use of this source code is governed by an MIT-style license that can be
2290
+ * found in the LICENSE file at https://angular.io/license
2291
+ */
2197
2292
  var EMPTY_INSTRUCTION_MAP = new ElementInstructionMap();
2198
2293
  var TimelineAnimationEngine = /** @class */ (function () {
2199
- function TimelineAnimationEngine(_driver, _normalizer) {
2294
+ function TimelineAnimationEngine(bodyNode, _driver, _normalizer) {
2295
+ this.bodyNode = bodyNode;
2200
2296
  this._driver = _driver;
2201
2297
  this._normalizer = _normalizer;
2202
2298
  this._animations = {};
@@ -2315,6 +2411,13 @@ var TimelineAnimationEngine = /** @class */ (function () {
2315
2411
  return TimelineAnimationEngine;
2316
2412
  }());
2317
2413
 
2414
+ /**
2415
+ * @license
2416
+ * Copyright Google Inc. All Rights Reserved.
2417
+ *
2418
+ * Use of this source code is governed by an MIT-style license that can be
2419
+ * found in the LICENSE file at https://angular.io/license
2420
+ */
2318
2421
  var QUEUED_CLASSNAME = 'ng-animate-queued';
2319
2422
  var QUEUED_SELECTOR = '.ng-animate-queued';
2320
2423
  var DISABLED_CLASSNAME = 'ng-animate-disabled';
@@ -2364,7 +2467,7 @@ var StateValue = /** @class */ (function () {
2364
2467
  StateValue.prototype.absorbOptions = function (options) {
2365
2468
  var newParams = options.params;
2366
2469
  if (newParams) {
2367
- var oldParams_1 = (this.options.params);
2470
+ var oldParams_1 = this.options.params;
2368
2471
  Object.keys(newParams).forEach(function (prop) {
2369
2472
  if (oldParams_1[prop] == null) {
2370
2473
  oldParams_1[prop] = newParams[prop];
@@ -2376,7 +2479,6 @@ var StateValue = /** @class */ (function () {
2376
2479
  }());
2377
2480
  var VOID_VALUE = 'void';
2378
2481
  var DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE);
2379
- var DELETED_STATE_VALUE = new StateValue('DELETED');
2380
2482
  var AnimationTransitionNamespace = /** @class */ (function () {
2381
2483
  function AnimationTransitionNamespace(id, hostElement, _engine) {
2382
2484
  this.id = id;
@@ -2410,9 +2512,6 @@ var AnimationTransitionNamespace = /** @class */ (function () {
2410
2512
  triggersWithStates[name] = DEFAULT_STATE_VALUE;
2411
2513
  }
2412
2514
  return function () {
2413
- // the event listener is removed AFTER the flush has occurred such
2414
- // that leave animations callbacks can fire (otherwise if the node
2415
- // is removed in between then the listeners would be deregistered)
2416
2515
  // the event listener is removed AFTER the flush has occurred such
2417
2516
  // that leave animations callbacks can fire (otherwise if the node
2418
2517
  // is removed in between then the listeners would be deregistered)
@@ -2465,9 +2564,6 @@ var AnimationTransitionNamespace = /** @class */ (function () {
2465
2564
  if (!fromState) {
2466
2565
  fromState = DEFAULT_STATE_VALUE;
2467
2566
  }
2468
- else if (fromState === DELETED_STATE_VALUE) {
2469
- return player;
2470
- }
2471
2567
  var isRemoval = toState.value === VOID_VALUE;
2472
2568
  // normally this isn't reached by here, however, if an object expression
2473
2569
  // is passed in then it may be a new object each time. Comparing the value
@@ -2609,7 +2705,7 @@ var AnimationTransitionNamespace = /** @class */ (function () {
2609
2705
  visitedTriggers_1.add(triggerName);
2610
2706
  var trigger = _this._triggers[triggerName];
2611
2707
  var transition = trigger.fallbackTransition;
2612
- var elementStates = (_this._engine.statesByElement.get(element));
2708
+ var elementStates = _this._engine.statesByElement.get(element);
2613
2709
  var fromState = elementStates[triggerName] || DEFAULT_STATE_VALUE;
2614
2710
  var toState = new StateValue(VOID_VALUE);
2615
2711
  var player = new TransitionAnimationPlayer(_this.id, triggerName, element);
@@ -2733,7 +2829,8 @@ var AnimationTransitionNamespace = /** @class */ (function () {
2733
2829
  return AnimationTransitionNamespace;
2734
2830
  }());
2735
2831
  var TransitionAnimationEngine = /** @class */ (function () {
2736
- function TransitionAnimationEngine(driver, _normalizer) {
2832
+ function TransitionAnimationEngine(bodyNode, driver, _normalizer) {
2833
+ this.bodyNode = bodyNode;
2737
2834
  this.driver = driver;
2738
2835
  this._normalizer = _normalizer;
2739
2836
  this.players = [];
@@ -2755,9 +2852,7 @@ var TransitionAnimationEngine = /** @class */ (function () {
2755
2852
  this.onRemovalComplete = function (element, context) { };
2756
2853
  }
2757
2854
  /** @internal */
2758
- /** @internal */
2759
- TransitionAnimationEngine.prototype._onRemovalComplete = /** @internal */
2760
- function (element, context) { this.onRemovalComplete(element, context); };
2855
+ TransitionAnimationEngine.prototype._onRemovalComplete = function (element, context) { this.onRemovalComplete(element, context); };
2761
2856
  Object.defineProperty(TransitionAnimationEngine.prototype, "queuedPlayers", {
2762
2857
  get: function () {
2763
2858
  var players = [];
@@ -2949,8 +3044,8 @@ var TransitionAnimationEngine = /** @class */ (function () {
2949
3044
  }
2950
3045
  return function () { };
2951
3046
  };
2952
- TransitionAnimationEngine.prototype._buildInstruction = function (entry, subTimelines, enterClassName, leaveClassName) {
2953
- return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, enterClassName, leaveClassName, entry.fromState.options, entry.toState.options, subTimelines);
3047
+ TransitionAnimationEngine.prototype._buildInstruction = function (entry, subTimelines, enterClassName, leaveClassName, skipBuildAst) {
3048
+ return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, enterClassName, leaveClassName, entry.fromState.options, entry.toState.options, subTimelines, skipBuildAst);
2954
3049
  };
2955
3050
  TransitionAnimationEngine.prototype.destroyInnerAnimations = function (containerElement) {
2956
3051
  var _this = this;
@@ -2976,10 +3071,6 @@ var TransitionAnimationEngine = /** @class */ (function () {
2976
3071
  }
2977
3072
  });
2978
3073
  }
2979
- var stateMap = this.statesByElement.get(element);
2980
- if (stateMap) {
2981
- Object.keys(stateMap).forEach(function (triggerName) { return stateMap[triggerName] = DELETED_STATE_VALUE; });
2982
- }
2983
3074
  };
2984
3075
  TransitionAnimationEngine.prototype.finishActiveQueriedAnimationOnElement = function (element) {
2985
3076
  var players = this.playersByQueriedElement.get(element);
@@ -3091,7 +3182,7 @@ var TransitionAnimationEngine = /** @class */ (function () {
3091
3182
  disabledElementsSet.add(nodesThatAreDisabled[i_1]);
3092
3183
  }
3093
3184
  });
3094
- var bodyNode = getBodyNode();
3185
+ var bodyNode = this.bodyNode;
3095
3186
  var allTriggerElements = Array.from(this.statesByElement.keys());
3096
3187
  var enterNodeMap = buildRootMap(allTriggerElements, this.collectedEnterElements);
3097
3188
  // this must occur before the instructions are built below such that
@@ -3130,11 +3221,11 @@ var TransitionAnimationEngine = /** @class */ (function () {
3130
3221
  });
3131
3222
  cleanupFns.push(function () {
3132
3223
  enterNodeMap.forEach(function (nodes, root) {
3133
- var className = (enterNodeMapIds.get(root));
3224
+ var className = enterNodeMapIds.get(root);
3134
3225
  nodes.forEach(function (node) { return removeClass(node, className); });
3135
3226
  });
3136
3227
  leaveNodeMap.forEach(function (nodes, root) {
3137
- var className = (leaveNodeMapIds.get(root));
3228
+ var className = leaveNodeMapIds.get(root);
3138
3229
  nodes.forEach(function (node) { return removeClass(node, className); });
3139
3230
  });
3140
3231
  allLeaveNodes.forEach(function (element) { _this.processLeaveNode(element); });
@@ -3155,17 +3246,24 @@ var TransitionAnimationEngine = /** @class */ (function () {
3155
3246
  return;
3156
3247
  }
3157
3248
  }
3158
- if (!bodyNode || !_this.driver.containsElement(bodyNode, element)) {
3159
- player.destroy();
3160
- return;
3161
- }
3162
- var leaveClassName = (leaveNodeMapIds.get(element));
3163
- var enterClassName = (enterNodeMapIds.get(element));
3164
- var instruction = (_this._buildInstruction(entry, subTimelines, enterClassName, leaveClassName));
3249
+ var nodeIsOrphaned = !bodyNode || !_this.driver.containsElement(bodyNode, element);
3250
+ var leaveClassName = leaveNodeMapIds.get(element);
3251
+ var enterClassName = enterNodeMapIds.get(element);
3252
+ var instruction = _this._buildInstruction(entry, subTimelines, enterClassName, leaveClassName, nodeIsOrphaned);
3165
3253
  if (instruction.errors && instruction.errors.length) {
3166
3254
  erroneousTransitions.push(instruction);
3167
3255
  return;
3168
3256
  }
3257
+ // even though the element may not be apart of the DOM, it may
3258
+ // still be added at a later point (due to the mechanics of content
3259
+ // projection and/or dynamic component insertion) therefore it's
3260
+ // important we still style the element.
3261
+ if (nodeIsOrphaned) {
3262
+ player.onStart(function () { return eraseStyles(element, instruction.fromStyles); });
3263
+ player.onDestroy(function () { return setStyles(element, instruction.toStyles); });
3264
+ skippedPlayers.push(player);
3265
+ return;
3266
+ }
3169
3267
  // if a unmatched transition is queued to go then it SHOULD NOT render
3170
3268
  // an animation and cancel the previously running animations.
3171
3269
  if (entry.isFallbackTransition) {
@@ -3187,7 +3285,7 @@ var TransitionAnimationEngine = /** @class */ (function () {
3187
3285
  instruction.preStyleProps.forEach(function (stringMap, element) {
3188
3286
  var props = Object.keys(stringMap);
3189
3287
  if (props.length) {
3190
- var setVal_1 = (allPreStyleElements.get(element));
3288
+ var setVal_1 = allPreStyleElements.get(element);
3191
3289
  if (!setVal_1) {
3192
3290
  allPreStyleElements.set(element, setVal_1 = new Set());
3193
3291
  }
@@ -3196,7 +3294,7 @@ var TransitionAnimationEngine = /** @class */ (function () {
3196
3294
  });
3197
3295
  instruction.postStyleProps.forEach(function (stringMap, element) {
3198
3296
  var props = Object.keys(stringMap);
3199
- var setVal = (allPostStyleElements.get(element));
3297
+ var setVal = allPostStyleElements.get(element);
3200
3298
  if (!setVal) {
3201
3299
  allPostStyleElements.set(element, setVal = new Set());
3202
3300
  }
@@ -3625,9 +3723,7 @@ var TransitionAnimationPlayer = /** @class */ (function () {
3625
3723
  };
3626
3724
  TransitionAnimationPlayer.prototype.getPosition = function () { return this.queued ? 0 : this._player.getPosition(); };
3627
3725
  /* @internal */
3628
- /* @internal */
3629
- TransitionAnimationPlayer.prototype.triggerCallback = /* @internal */
3630
- function (phaseName) {
3726
+ TransitionAnimationPlayer.prototype.triggerCallback = function (phaseName) {
3631
3727
  var p = this._player;
3632
3728
  if (p.triggerCallback) {
3633
3729
  p.triggerCallback(phaseName);
@@ -3729,15 +3825,12 @@ function buildRootMap(roots, nodes) {
3729
3825
  return root;
3730
3826
  var parent = node.parentNode;
3731
3827
  if (rootMap.has(parent)) {
3732
- // ngIf inside @trigger
3733
3828
  root = parent;
3734
3829
  }
3735
3830
  else if (nodeSet.has(parent)) {
3736
- // ngIf inside ngIf
3737
3831
  root = NULL_NODE;
3738
3832
  }
3739
3833
  else {
3740
- // recurse upwards
3741
3834
  root = getRoot(parent);
3742
3835
  }
3743
3836
  localRootMap.set(node, root);
@@ -3822,14 +3915,15 @@ function replacePostStylesAsPre(element, allPreStyleElements, allPostStyleElemen
3822
3915
  }
3823
3916
 
3824
3917
  var AnimationEngine = /** @class */ (function () {
3825
- function AnimationEngine(_driver, normalizer) {
3918
+ function AnimationEngine(bodyNode, _driver, normalizer) {
3826
3919
  var _this = this;
3920
+ this.bodyNode = bodyNode;
3827
3921
  this._driver = _driver;
3828
3922
  this._triggerCache = {};
3829
3923
  // this method is designed to be overridden by the code that uses this engine
3830
3924
  this.onRemovalComplete = function (element, context) { };
3831
- this._transitionEngine = new TransitionAnimationEngine(_driver, normalizer);
3832
- this._timelineEngine = new TimelineAnimationEngine(_driver, normalizer);
3925
+ this._transitionEngine = new TransitionAnimationEngine(bodyNode, _driver, normalizer);
3926
+ this._timelineEngine = new TimelineAnimationEngine(bodyNode, _driver, normalizer);
3833
3927
  this._transitionEngine.onRemovalComplete = function (element, context) {
3834
3928
  return _this.onRemovalComplete(element, context);
3835
3929
  };
@@ -4127,9 +4221,7 @@ var CssKeyframesPlayer = /** @class */ (function () {
4127
4221
  this._styler = new ElementAnimationStyleHandler(this.element, this.animationName, this._duration, this._delay, this.easing, DEFAULT_FILL_MODE, function () { return _this.finish(); });
4128
4222
  };
4129
4223
  /* @internal */
4130
- /* @internal */
4131
- CssKeyframesPlayer.prototype.triggerCallback = /* @internal */
4132
- function (phaseName) {
4224
+ CssKeyframesPlayer.prototype.triggerCallback = function (phaseName) {
4133
4225
  var methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
4134
4226
  methods.forEach(function (fn) { return fn(); });
4135
4227
  methods.length = 0;
@@ -4151,6 +4243,13 @@ var CssKeyframesPlayer = /** @class */ (function () {
4151
4243
  return CssKeyframesPlayer;
4152
4244
  }());
4153
4245
 
4246
+ /**
4247
+ * @license
4248
+ * Copyright Google Inc. All Rights Reserved.
4249
+ *
4250
+ * Use of this source code is governed by an MIT-style license that can be
4251
+ * found in the LICENSE file at https://angular.io/license
4252
+ */
4154
4253
  var DirectStylePlayer = /** @class */ (function (_super) {
4155
4254
  __extends(DirectStylePlayer, _super);
4156
4255
  function DirectStylePlayer(element, styles) {
@@ -4355,9 +4454,7 @@ var WebAnimationsPlayer = /** @class */ (function () {
4355
4454
  }
4356
4455
  };
4357
4456
  /** @internal */
4358
- /** @internal */
4359
- WebAnimationsPlayer.prototype._triggerWebAnimation = /** @internal */
4360
- function (element, keyframes, options) {
4457
+ WebAnimationsPlayer.prototype._triggerWebAnimation = function (element, keyframes, options) {
4361
4458
  // jscompiler doesn't seem to know animate is a native property because it's not fully
4362
4459
  // supported yet across common browsers (we polyfill it for Edge/Safari) [CL #143630929]
4363
4460
  return element['animate'](keyframes, options);
@@ -4429,9 +4526,7 @@ var WebAnimationsPlayer = /** @class */ (function () {
4429
4526
  this.currentSnapshot = styles;
4430
4527
  };
4431
4528
  /* @internal */
4432
- /* @internal */
4433
- WebAnimationsPlayer.prototype.triggerCallback = /* @internal */
4434
- function (phaseName) {
4529
+ WebAnimationsPlayer.prototype.triggerCallback = function (phaseName) {
4435
4530
  var methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
4436
4531
  methods.forEach(function (fn) { return fn(); });
4437
4532
  methods.length = 0;
@@ -4487,7 +4582,7 @@ function supportsWebAnimations() {
4487
4582
  return typeof getElementAnimateFn() === 'function';
4488
4583
  }
4489
4584
  function getElementAnimateFn() {
4490
- return (typeof Element !== 'undefined' && Element.prototype['animate']) || {};
4585
+ return (isBrowser() && Element.prototype['animate']) || {};
4491
4586
  }
4492
4587
 
4493
4588
  /**
@@ -4505,6 +4600,24 @@ function getElementAnimateFn() {
4505
4600
  * Use of this source code is governed by an MIT-style license that can be
4506
4601
  * found in the LICENSE file at https://angular.io/license
4507
4602
  */
4603
+ /**
4604
+ * @module
4605
+ * @description
4606
+ * Entry point for all animation APIs of the animation browser package.
4607
+ */
4608
+
4609
+ /**
4610
+ * @license
4611
+ * Copyright Google Inc. All Rights Reserved.
4612
+ *
4613
+ * Use of this source code is governed by an MIT-style license that can be
4614
+ * found in the LICENSE file at https://angular.io/license
4615
+ */
4616
+ /**
4617
+ * @module
4618
+ * @description
4619
+ * Entry point for all public APIs of this package.
4620
+ */
4508
4621
 
4509
4622
  /**
4510
4623
  * @license
@@ -4513,6 +4626,10 @@ function getElementAnimateFn() {
4513
4626
  * Use of this source code is governed by an MIT-style license that can be
4514
4627
  * found in the LICENSE file at https://angular.io/license
4515
4628
  */
4629
+ // This file is not used to build this module. It is only used during editing
4630
+ // by the TypeScript language service and during build for verifcation. `ngc`
4631
+ // replaces this file with production index.ts when it rewrites private symbol
4632
+ // names.
4516
4633
 
4517
4634
  /**
4518
4635
  * Generated bundle index. Do not edit.