animations-browser-testing.umd.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/animations/browser')) :
  8. typeof define === 'function' && define.amd ? define('@angular/animations/browser/testing', ['exports', '@angular/animations', '@angular/animations/browser'], factory) :
  9. (global = global || self, factory((global.ng = global.ng || {}, global.ng.animations = global.ng.animations || {}, global.ng.animations.browser = global.ng.animations.browser || {}, global.ng.animations.browser.testing = {}), global.ng.animations, global.ng.animations.browser));
  10. }(this, function (exports, animations, browser) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = function(d, b) {
  25. extendStatics = Object.setPrototypeOf ||
  26. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  27. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  28. return extendStatics(d, b);
  29. };
  30. function __extends(d, b) {
  31. extendStatics(d, b);
  32. function __() { this.constructor = d; }
  33. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34. }
  35. /**
  36. * @publicApi
  37. */
  38. var MockAnimationDriver = /** @class */ (function () {
  39. function MockAnimationDriver() {
  40. }
  41. MockAnimationDriver.prototype.validateStyleProperty = function (prop) { return browser.ɵvalidateStyleProperty(prop); };
  42. MockAnimationDriver.prototype.matchesElement = function (element, selector) {
  43. return browser.ɵmatchesElement(element, selector);
  44. };
  45. MockAnimationDriver.prototype.containsElement = function (elm1, elm2) { return browser.ɵcontainsElement(elm1, elm2); };
  46. MockAnimationDriver.prototype.query = function (element, selector, multi) {
  47. return browser.ɵinvokeQuery(element, selector, multi);
  48. };
  49. MockAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) {
  50. return defaultValue || '';
  51. };
  52. MockAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) {
  53. if (previousPlayers === void 0) { previousPlayers = []; }
  54. var player = new MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers);
  55. MockAnimationDriver.log.push(player);
  56. return player;
  57. };
  58. MockAnimationDriver.log = [];
  59. return MockAnimationDriver;
  60. }());
  61. /**
  62. * @publicApi
  63. */
  64. var MockAnimationPlayer = /** @class */ (function (_super) {
  65. __extends(MockAnimationPlayer, _super);
  66. function MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers) {
  67. var _this = _super.call(this, duration, delay) || this;
  68. _this.element = element;
  69. _this.keyframes = keyframes;
  70. _this.duration = duration;
  71. _this.delay = delay;
  72. _this.easing = easing;
  73. _this.previousPlayers = previousPlayers;
  74. _this.__finished = false;
  75. _this.__started = false;
  76. _this.previousStyles = {};
  77. _this._onInitFns = [];
  78. _this.currentSnapshot = {};
  79. if (browser.ɵallowPreviousPlayerStylesMerge(duration, delay)) {
  80. previousPlayers.forEach(function (player) {
  81. if (player instanceof MockAnimationPlayer) {
  82. var styles_1 = player.currentSnapshot;
  83. Object.keys(styles_1).forEach(function (prop) { return _this.previousStyles[prop] = styles_1[prop]; });
  84. }
  85. });
  86. }
  87. return _this;
  88. }
  89. /* @internal */
  90. MockAnimationPlayer.prototype.onInit = function (fn) { this._onInitFns.push(fn); };
  91. /* @internal */
  92. MockAnimationPlayer.prototype.init = function () {
  93. _super.prototype.init.call(this);
  94. this._onInitFns.forEach(function (fn) { return fn(); });
  95. this._onInitFns = [];
  96. };
  97. MockAnimationPlayer.prototype.finish = function () {
  98. _super.prototype.finish.call(this);
  99. this.__finished = true;
  100. };
  101. MockAnimationPlayer.prototype.destroy = function () {
  102. _super.prototype.destroy.call(this);
  103. this.__finished = true;
  104. };
  105. /* @internal */
  106. MockAnimationPlayer.prototype.triggerMicrotask = function () { };
  107. MockAnimationPlayer.prototype.play = function () {
  108. _super.prototype.play.call(this);
  109. this.__started = true;
  110. };
  111. MockAnimationPlayer.prototype.hasStarted = function () { return this.__started; };
  112. MockAnimationPlayer.prototype.beforeDestroy = function () {
  113. var _this = this;
  114. var captures = {};
  115. Object.keys(this.previousStyles).forEach(function (prop) {
  116. captures[prop] = _this.previousStyles[prop];
  117. });
  118. if (this.hasStarted()) {
  119. // when assembling the captured styles, it's important that
  120. // we build the keyframe styles in the following order:
  121. // {other styles within keyframes, ... previousStyles }
  122. this.keyframes.forEach(function (kf) {
  123. Object.keys(kf).forEach(function (prop) {
  124. if (prop != 'offset') {
  125. captures[prop] = _this.__finished ? kf[prop] : animations.AUTO_STYLE;
  126. }
  127. });
  128. });
  129. }
  130. this.currentSnapshot = captures;
  131. };
  132. return MockAnimationPlayer;
  133. }(animations.NoopAnimationPlayer));
  134. /**
  135. * @license
  136. * Copyright Google Inc. All Rights Reserved.
  137. *
  138. * Use of this source code is governed by an MIT-style license that can be
  139. * found in the LICENSE file at https://angular.io/license
  140. */
  141. /**
  142. * @license
  143. * Copyright Google Inc. All Rights Reserved.
  144. *
  145. * Use of this source code is governed by an MIT-style license that can be
  146. * found in the LICENSE file at https://angular.io/license
  147. */
  148. /**
  149. * @license
  150. * Copyright Google Inc. All Rights Reserved.
  151. *
  152. * Use of this source code is governed by an MIT-style license that can be
  153. * found in the LICENSE file at https://angular.io/license
  154. */
  155. /**
  156. * Generated bundle index. Do not edit.
  157. */
  158. exports.MockAnimationDriver = MockAnimationDriver;
  159. exports.MockAnimationPlayer = MockAnimationPlayer;
  160. Object.defineProperty(exports, '__esModule', { value: true });
  161. }));
  162. //# sourceMappingURL=animations-browser-testing.umd.js.map