1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | (function (global, factory) {
|
8 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/animations/browser')) :
|
9 | typeof define === 'function' && define.amd ? define('@angular/animations/browser/testing', ['exports', '@angular/animations', '@angular/animations/browser'], factory) :
|
10 | (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));
|
11 | }(this, function (exports, animations, browser) { 'use strict';
|
12 |
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | var extendStatics = function(d, b) {
|
30 | extendStatics = Object.setPrototypeOf ||
|
31 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
32 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
33 | return extendStatics(d, b);
|
34 | };
|
35 |
|
36 | function __extends(d, b) {
|
37 | extendStatics(d, b);
|
38 | function __() { this.constructor = d; }
|
39 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
40 | }
|
41 |
|
42 | var __assign = function() {
|
43 | __assign = Object.assign || function __assign(t) {
|
44 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
45 | s = arguments[i];
|
46 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
47 | }
|
48 | return t;
|
49 | };
|
50 | return __assign.apply(this, arguments);
|
51 | };
|
52 |
|
53 | function __rest(s, e) {
|
54 | var t = {};
|
55 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
56 | t[p] = s[p];
|
57 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
58 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
59 | t[p[i]] = s[p[i]];
|
60 | return t;
|
61 | }
|
62 |
|
63 | function __decorate(decorators, target, key, desc) {
|
64 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
65 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
66 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
67 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
68 | }
|
69 |
|
70 | function __param(paramIndex, decorator) {
|
71 | return function (target, key) { decorator(target, key, paramIndex); }
|
72 | }
|
73 |
|
74 | function __metadata(metadataKey, metadataValue) {
|
75 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
76 | }
|
77 |
|
78 | function __awaiter(thisArg, _arguments, P, generator) {
|
79 | return new (P || (P = Promise))(function (resolve, reject) {
|
80 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
81 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
82 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
83 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
84 | });
|
85 | }
|
86 |
|
87 | function __generator(thisArg, body) {
|
88 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
89 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
90 | function verb(n) { return function (v) { return step([n, v]); }; }
|
91 | function step(op) {
|
92 | if (f) throw new TypeError("Generator is already executing.");
|
93 | while (_) try {
|
94 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
95 | if (y = 0, t) op = [op[0] & 2, t.value];
|
96 | switch (op[0]) {
|
97 | case 0: case 1: t = op; break;
|
98 | case 4: _.label++; return { value: op[1], done: false };
|
99 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
100 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
101 | default:
|
102 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
103 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
104 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
105 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
106 | if (t[2]) _.ops.pop();
|
107 | _.trys.pop(); continue;
|
108 | }
|
109 | op = body.call(thisArg, _);
|
110 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
111 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
112 | }
|
113 | }
|
114 |
|
115 | function __exportStar(m, exports) {
|
116 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
117 | }
|
118 |
|
119 | function __values(o) {
|
120 | var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
121 | if (m) return m.call(o);
|
122 | return {
|
123 | next: function () {
|
124 | if (o && i >= o.length) o = void 0;
|
125 | return { value: o && o[i++], done: !o };
|
126 | }
|
127 | };
|
128 | }
|
129 |
|
130 | function __read(o, n) {
|
131 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
132 | if (!m) return o;
|
133 | var i = m.call(o), r, ar = [], e;
|
134 | try {
|
135 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
136 | }
|
137 | catch (error) { e = { error: error }; }
|
138 | finally {
|
139 | try {
|
140 | if (r && !r.done && (m = i["return"])) m.call(i);
|
141 | }
|
142 | finally { if (e) throw e.error; }
|
143 | }
|
144 | return ar;
|
145 | }
|
146 |
|
147 | function __spread() {
|
148 | for (var ar = [], i = 0; i < arguments.length; i++)
|
149 | ar = ar.concat(__read(arguments[i]));
|
150 | return ar;
|
151 | }
|
152 |
|
153 | function __await(v) {
|
154 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
155 | }
|
156 |
|
157 | function __asyncGenerator(thisArg, _arguments, generator) {
|
158 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
159 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
160 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
161 | function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
162 | function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
163 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
164 | function fulfill(value) { resume("next", value); }
|
165 | function reject(value) { resume("throw", value); }
|
166 | function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
167 | }
|
168 |
|
169 | function __asyncDelegator(o) {
|
170 | var i, p;
|
171 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
172 | function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
173 | }
|
174 |
|
175 | function __asyncValues(o) {
|
176 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
177 | var m = o[Symbol.asyncIterator], i;
|
178 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
179 | function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
180 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
181 | }
|
182 |
|
183 | function __makeTemplateObject(cooked, raw) {
|
184 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
185 | return cooked;
|
186 | };
|
187 |
|
188 | function __importStar(mod) {
|
189 | if (mod && mod.__esModule) return mod;
|
190 | var result = {};
|
191 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
192 | result.default = mod;
|
193 | return result;
|
194 | }
|
195 |
|
196 | function __importDefault(mod) {
|
197 | return (mod && mod.__esModule) ? mod : { default: mod };
|
198 | }
|
199 |
|
200 | |
201 |
|
202 |
|
203 | var MockAnimationDriver = (function () {
|
204 | function MockAnimationDriver() {
|
205 | }
|
206 | MockAnimationDriver.prototype.validateStyleProperty = function (prop) { return browser.ɵvalidateStyleProperty(prop); };
|
207 | MockAnimationDriver.prototype.matchesElement = function (element, selector) {
|
208 | return browser.ɵmatchesElement(element, selector);
|
209 | };
|
210 | MockAnimationDriver.prototype.containsElement = function (elm1, elm2) { return browser.ɵcontainsElement(elm1, elm2); };
|
211 | MockAnimationDriver.prototype.query = function (element, selector, multi) {
|
212 | return browser.ɵinvokeQuery(element, selector, multi);
|
213 | };
|
214 | MockAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) {
|
215 | return defaultValue || '';
|
216 | };
|
217 | MockAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) {
|
218 | if (previousPlayers === void 0) { previousPlayers = []; }
|
219 | var player = new MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers);
|
220 | MockAnimationDriver.log.push(player);
|
221 | return player;
|
222 | };
|
223 | MockAnimationDriver.log = [];
|
224 | return MockAnimationDriver;
|
225 | }());
|
226 | |
227 |
|
228 |
|
229 | var MockAnimationPlayer = (function (_super) {
|
230 | __extends(MockAnimationPlayer, _super);
|
231 | function MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers) {
|
232 | var _this = _super.call(this, duration, delay) || this;
|
233 | _this.element = element;
|
234 | _this.keyframes = keyframes;
|
235 | _this.duration = duration;
|
236 | _this.delay = delay;
|
237 | _this.easing = easing;
|
238 | _this.previousPlayers = previousPlayers;
|
239 | _this.__finished = false;
|
240 | _this.__started = false;
|
241 | _this.previousStyles = {};
|
242 | _this._onInitFns = [];
|
243 | _this.currentSnapshot = {};
|
244 | if (browser.ɵallowPreviousPlayerStylesMerge(duration, delay)) {
|
245 | previousPlayers.forEach(function (player) {
|
246 | if (player instanceof MockAnimationPlayer) {
|
247 | var styles_1 = player.currentSnapshot;
|
248 | Object.keys(styles_1).forEach(function (prop) { return _this.previousStyles[prop] = styles_1[prop]; });
|
249 | }
|
250 | });
|
251 | }
|
252 | return _this;
|
253 | }
|
254 |
|
255 | MockAnimationPlayer.prototype.onInit = function (fn) { this._onInitFns.push(fn); };
|
256 |
|
257 | MockAnimationPlayer.prototype.init = function () {
|
258 | _super.prototype.init.call(this);
|
259 | this._onInitFns.forEach(function (fn) { return fn(); });
|
260 | this._onInitFns = [];
|
261 | };
|
262 | MockAnimationPlayer.prototype.finish = function () {
|
263 | _super.prototype.finish.call(this);
|
264 | this.__finished = true;
|
265 | };
|
266 | MockAnimationPlayer.prototype.destroy = function () {
|
267 | _super.prototype.destroy.call(this);
|
268 | this.__finished = true;
|
269 | };
|
270 |
|
271 | MockAnimationPlayer.prototype.triggerMicrotask = function () { };
|
272 | MockAnimationPlayer.prototype.play = function () {
|
273 | _super.prototype.play.call(this);
|
274 | this.__started = true;
|
275 | };
|
276 | MockAnimationPlayer.prototype.hasStarted = function () { return this.__started; };
|
277 | MockAnimationPlayer.prototype.beforeDestroy = function () {
|
278 | var _this = this;
|
279 | var captures = {};
|
280 | Object.keys(this.previousStyles).forEach(function (prop) {
|
281 | captures[prop] = _this.previousStyles[prop];
|
282 | });
|
283 | if (this.hasStarted()) {
|
284 |
|
285 |
|
286 |
|
287 | this.keyframes.forEach(function (kf) {
|
288 | Object.keys(kf).forEach(function (prop) {
|
289 | if (prop != 'offset') {
|
290 | captures[prop] = _this.__finished ? kf[prop] : animations.AUTO_STYLE;
|
291 | }
|
292 | });
|
293 | });
|
294 | }
|
295 | this.currentSnapshot = captures;
|
296 | };
|
297 | return MockAnimationPlayer;
|
298 | }(animations.NoopAnimationPlayer));
|
299 |
|
300 | |
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 | |
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 | |
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | |
325 |
|
326 |
|
327 |
|
328 | exports.MockAnimationDriver = MockAnimationDriver;
|
329 | exports.MockAnimationPlayer = MockAnimationPlayer;
|
330 |
|
331 | Object.defineProperty(exports, '__esModule', { value: true });
|
332 |
|
333 | }));
|
334 |
|