UNPKG

34.4 kBJavaScriptView Raw
1/**
2 * @license Angular v9.1.3
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7(function (global, factory) {
8 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser'), require('@angular/animations'), require('@angular/animations/browser'), require('@angular/common')) :
9 typeof define === 'function' && define.amd ? define('@angular/platform-browser/animations', ['exports', '@angular/core', '@angular/platform-browser', '@angular/animations', '@angular/animations/browser', '@angular/common'], factory) :
10 (global = global || self, factory((global.ng = global.ng || {}, global.ng.platformBrowser = global.ng.platformBrowser || {}, global.ng.platformBrowser.animations = {}), global.ng.core, global.ng.platformBrowser, global.ng.animations, global.ng.animations.browser, global.ng.common));
11}(this, (function (exports, core, platformBrowser, animations, browser, common) { 'use strict';
12
13 /*! *****************************************************************************
14 Copyright (c) Microsoft Corporation. All rights reserved.
15 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
16 this file except in compliance with the License. You may obtain a copy of the
17 License at http://www.apache.org/licenses/LICENSE-2.0
18
19 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
21 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
22 MERCHANTABLITY OR NON-INFRINGEMENT.
23
24 See the Apache Version 2.0 License for specific language governing permissions
25 and limitations under the License.
26 ***************************************************************************** */
27 /* global Reflect, Promise */
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++) {
59 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60 t[p[i]] = s[p[i]];
61 }
62 return t;
63 }
64
65 function __decorate(decorators, target, key, desc) {
66 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
67 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
68 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;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71
72 function __param(paramIndex, decorator) {
73 return function (target, key) { decorator(target, key, paramIndex); }
74 }
75
76 function __metadata(metadataKey, metadataValue) {
77 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
78 }
79
80 function __awaiter(thisArg, _arguments, P, generator) {
81 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
82 return new (P || (P = Promise))(function (resolve, reject) {
83 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
84 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
85 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
86 step((generator = generator.apply(thisArg, _arguments || [])).next());
87 });
88 }
89
90 function __generator(thisArg, body) {
91 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
92 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
93 function verb(n) { return function (v) { return step([n, v]); }; }
94 function step(op) {
95 if (f) throw new TypeError("Generator is already executing.");
96 while (_) try {
97 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;
98 if (y = 0, t) op = [op[0] & 2, t.value];
99 switch (op[0]) {
100 case 0: case 1: t = op; break;
101 case 4: _.label++; return { value: op[1], done: false };
102 case 5: _.label++; y = op[1]; op = [0]; continue;
103 case 7: op = _.ops.pop(); _.trys.pop(); continue;
104 default:
105 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
106 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
107 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
108 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
109 if (t[2]) _.ops.pop();
110 _.trys.pop(); continue;
111 }
112 op = body.call(thisArg, _);
113 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
114 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
115 }
116 }
117
118 function __exportStar(m, exports) {
119 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
120 }
121
122 function __values(o) {
123 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
124 if (m) return m.call(o);
125 if (o && typeof o.length === "number") return {
126 next: function () {
127 if (o && i >= o.length) o = void 0;
128 return { value: o && o[i++], done: !o };
129 }
130 };
131 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
132 }
133
134 function __read(o, n) {
135 var m = typeof Symbol === "function" && o[Symbol.iterator];
136 if (!m) return o;
137 var i = m.call(o), r, ar = [], e;
138 try {
139 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
140 }
141 catch (error) { e = { error: error }; }
142 finally {
143 try {
144 if (r && !r.done && (m = i["return"])) m.call(i);
145 }
146 finally { if (e) throw e.error; }
147 }
148 return ar;
149 }
150
151 function __spread() {
152 for (var ar = [], i = 0; i < arguments.length; i++)
153 ar = ar.concat(__read(arguments[i]));
154 return ar;
155 }
156
157 function __spreadArrays() {
158 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
159 for (var r = Array(s), k = 0, i = 0; i < il; i++)
160 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
161 r[k] = a[j];
162 return r;
163 };
164
165 function __await(v) {
166 return this instanceof __await ? (this.v = v, this) : new __await(v);
167 }
168
169 function __asyncGenerator(thisArg, _arguments, generator) {
170 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
171 var g = generator.apply(thisArg, _arguments || []), i, q = [];
172 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
173 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); }); }; }
174 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
175 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
176 function fulfill(value) { resume("next", value); }
177 function reject(value) { resume("throw", value); }
178 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
179 }
180
181 function __asyncDelegator(o) {
182 var i, p;
183 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
184 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; }
185 }
186
187 function __asyncValues(o) {
188 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
189 var m = o[Symbol.asyncIterator], i;
190 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);
191 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); }); }; }
192 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
193 }
194
195 function __makeTemplateObject(cooked, raw) {
196 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
197 return cooked;
198 };
199
200 function __importStar(mod) {
201 if (mod && mod.__esModule) return mod;
202 var result = {};
203 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
204 result.default = mod;
205 return result;
206 }
207
208 function __importDefault(mod) {
209 return (mod && mod.__esModule) ? mod : { default: mod };
210 }
211
212 function __classPrivateFieldGet(receiver, privateMap) {
213 if (!privateMap.has(receiver)) {
214 throw new TypeError("attempted to get private field on non-instance");
215 }
216 return privateMap.get(receiver);
217 }
218
219 function __classPrivateFieldSet(receiver, privateMap, value) {
220 if (!privateMap.has(receiver)) {
221 throw new TypeError("attempted to set private field on non-instance");
222 }
223 privateMap.set(receiver, value);
224 return value;
225 }
226
227 var BrowserAnimationBuilder = /** @class */ (function (_super) {
228 __extends(BrowserAnimationBuilder, _super);
229 function BrowserAnimationBuilder(rootRenderer, doc) {
230 var _this = _super.call(this) || this;
231 _this._nextAnimationId = 0;
232 var typeData = { id: '0', encapsulation: core.ViewEncapsulation.None, styles: [], data: { animation: [] } };
233 _this._renderer = rootRenderer.createRenderer(doc.body, typeData);
234 return _this;
235 }
236 BrowserAnimationBuilder.prototype.build = function (animation) {
237 var id = this._nextAnimationId.toString();
238 this._nextAnimationId++;
239 var entry = Array.isArray(animation) ? animations.sequence(animation) : animation;
240 issueAnimationCommand(this._renderer, null, id, 'register', [entry]);
241 return new BrowserAnimationFactory(id, this._renderer);
242 };
243 BrowserAnimationBuilder = __decorate([
244 core.Injectable(),
245 __param(1, core.Inject(common.DOCUMENT)),
246 __metadata("design:paramtypes", [core.RendererFactory2, Object])
247 ], BrowserAnimationBuilder);
248 return BrowserAnimationBuilder;
249 }(animations.AnimationBuilder));
250 var BrowserAnimationFactory = /** @class */ (function (_super) {
251 __extends(BrowserAnimationFactory, _super);
252 function BrowserAnimationFactory(_id, _renderer) {
253 var _this = _super.call(this) || this;
254 _this._id = _id;
255 _this._renderer = _renderer;
256 return _this;
257 }
258 BrowserAnimationFactory.prototype.create = function (element, options) {
259 return new RendererAnimationPlayer(this._id, element, options || {}, this._renderer);
260 };
261 return BrowserAnimationFactory;
262 }(animations.AnimationFactory));
263 var RendererAnimationPlayer = /** @class */ (function () {
264 function RendererAnimationPlayer(id, element, options, _renderer) {
265 this.id = id;
266 this.element = element;
267 this._renderer = _renderer;
268 this.parentPlayer = null;
269 this._started = false;
270 this.totalTime = 0;
271 this._command('create', options);
272 }
273 RendererAnimationPlayer.prototype._listen = function (eventName, callback) {
274 return this._renderer.listen(this.element, "@@" + this.id + ":" + eventName, callback);
275 };
276 RendererAnimationPlayer.prototype._command = function (command) {
277 var args = [];
278 for (var _i = 1; _i < arguments.length; _i++) {
279 args[_i - 1] = arguments[_i];
280 }
281 return issueAnimationCommand(this._renderer, this.element, this.id, command, args);
282 };
283 RendererAnimationPlayer.prototype.onDone = function (fn) {
284 this._listen('done', fn);
285 };
286 RendererAnimationPlayer.prototype.onStart = function (fn) {
287 this._listen('start', fn);
288 };
289 RendererAnimationPlayer.prototype.onDestroy = function (fn) {
290 this._listen('destroy', fn);
291 };
292 RendererAnimationPlayer.prototype.init = function () {
293 this._command('init');
294 };
295 RendererAnimationPlayer.prototype.hasStarted = function () {
296 return this._started;
297 };
298 RendererAnimationPlayer.prototype.play = function () {
299 this._command('play');
300 this._started = true;
301 };
302 RendererAnimationPlayer.prototype.pause = function () {
303 this._command('pause');
304 };
305 RendererAnimationPlayer.prototype.restart = function () {
306 this._command('restart');
307 };
308 RendererAnimationPlayer.prototype.finish = function () {
309 this._command('finish');
310 };
311 RendererAnimationPlayer.prototype.destroy = function () {
312 this._command('destroy');
313 };
314 RendererAnimationPlayer.prototype.reset = function () {
315 this._command('reset');
316 };
317 RendererAnimationPlayer.prototype.setPosition = function (p) {
318 this._command('setPosition', p);
319 };
320 RendererAnimationPlayer.prototype.getPosition = function () {
321 return 0;
322 };
323 return RendererAnimationPlayer;
324 }());
325 function issueAnimationCommand(renderer, element, id, command, args) {
326 return renderer.setProperty(element, "@@" + id + ":" + command, args);
327 }
328
329 var ANIMATION_PREFIX = '@';
330 var DISABLE_ANIMATIONS_FLAG = '@.disabled';
331 var AnimationRendererFactory = /** @class */ (function () {
332 function AnimationRendererFactory(delegate, engine, _zone) {
333 this.delegate = delegate;
334 this.engine = engine;
335 this._zone = _zone;
336 this._currentId = 0;
337 this._microtaskId = 1;
338 this._animationCallbacksBuffer = [];
339 this._rendererCache = new Map();
340 this._cdRecurDepth = 0;
341 this.promise = Promise.resolve(0);
342 engine.onRemovalComplete = function (element, delegate) {
343 // Note: if an component element has a leave animation, and the component
344 // a host leave animation, the view engine will call `removeChild` for the parent
345 // component renderer as well as for the child component renderer.
346 // Therefore, we need to check if we already removed the element.
347 if (delegate && delegate.parentNode(element)) {
348 delegate.removeChild(element.parentNode, element);
349 }
350 };
351 }
352 AnimationRendererFactory.prototype.createRenderer = function (hostElement, type) {
353 var _this = this;
354 var EMPTY_NAMESPACE_ID = '';
355 // cache the delegates to find out which cached delegate can
356 // be used by which cached renderer
357 var delegate = this.delegate.createRenderer(hostElement, type);
358 if (!hostElement || !type || !type.data || !type.data['animation']) {
359 var renderer = this._rendererCache.get(delegate);
360 if (!renderer) {
361 renderer = new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine);
362 // only cache this result when the base renderer is used
363 this._rendererCache.set(delegate, renderer);
364 }
365 return renderer;
366 }
367 var componentId = type.id;
368 var namespaceId = type.id + '-' + this._currentId;
369 this._currentId++;
370 this.engine.register(namespaceId, hostElement);
371 var registerTrigger = function (trigger) {
372 if (Array.isArray(trigger)) {
373 trigger.forEach(registerTrigger);
374 }
375 else {
376 _this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger);
377 }
378 };
379 var animationTriggers = type.data['animation'];
380 animationTriggers.forEach(registerTrigger);
381 return new AnimationRenderer(this, namespaceId, delegate, this.engine);
382 };
383 AnimationRendererFactory.prototype.begin = function () {
384 this._cdRecurDepth++;
385 if (this.delegate.begin) {
386 this.delegate.begin();
387 }
388 };
389 AnimationRendererFactory.prototype._scheduleCountTask = function () {
390 var _this = this;
391 // always use promise to schedule microtask instead of use Zone
392 this.promise.then(function () {
393 _this._microtaskId++;
394 });
395 };
396 /** @internal */
397 AnimationRendererFactory.prototype.scheduleListenerCallback = function (count, fn, data) {
398 var _this = this;
399 if (count >= 0 && count < this._microtaskId) {
400 this._zone.run(function () { return fn(data); });
401 return;
402 }
403 if (this._animationCallbacksBuffer.length == 0) {
404 Promise.resolve(null).then(function () {
405 _this._zone.run(function () {
406 _this._animationCallbacksBuffer.forEach(function (tuple) {
407 var _a = __read(tuple, 2), fn = _a[0], data = _a[1];
408 fn(data);
409 });
410 _this._animationCallbacksBuffer = [];
411 });
412 });
413 }
414 this._animationCallbacksBuffer.push([fn, data]);
415 };
416 AnimationRendererFactory.prototype.end = function () {
417 var _this = this;
418 this._cdRecurDepth--;
419 // this is to prevent animations from running twice when an inner
420 // component does CD when a parent component instead has inserted it
421 if (this._cdRecurDepth == 0) {
422 this._zone.runOutsideAngular(function () {
423 _this._scheduleCountTask();
424 _this.engine.flush(_this._microtaskId);
425 });
426 }
427 if (this.delegate.end) {
428 this.delegate.end();
429 }
430 };
431 AnimationRendererFactory.prototype.whenRenderingDone = function () {
432 return this.engine.whenRenderingDone();
433 };
434 AnimationRendererFactory = __decorate([
435 core.Injectable(),
436 __metadata("design:paramtypes", [core.RendererFactory2, browser.ɵAnimationEngine, core.NgZone])
437 ], AnimationRendererFactory);
438 return AnimationRendererFactory;
439 }());
440 var BaseAnimationRenderer = /** @class */ (function () {
441 function BaseAnimationRenderer(namespaceId, delegate, engine) {
442 this.namespaceId = namespaceId;
443 this.delegate = delegate;
444 this.engine = engine;
445 this.destroyNode = this.delegate.destroyNode ? function (n) { return delegate.destroyNode(n); } : null;
446 }
447 Object.defineProperty(BaseAnimationRenderer.prototype, "data", {
448 get: function () {
449 return this.delegate.data;
450 },
451 enumerable: true,
452 configurable: true
453 });
454 BaseAnimationRenderer.prototype.destroy = function () {
455 this.engine.destroy(this.namespaceId, this.delegate);
456 this.delegate.destroy();
457 };
458 BaseAnimationRenderer.prototype.createElement = function (name, namespace) {
459 return this.delegate.createElement(name, namespace);
460 };
461 BaseAnimationRenderer.prototype.createComment = function (value) {
462 return this.delegate.createComment(value);
463 };
464 BaseAnimationRenderer.prototype.createText = function (value) {
465 return this.delegate.createText(value);
466 };
467 BaseAnimationRenderer.prototype.appendChild = function (parent, newChild) {
468 this.delegate.appendChild(parent, newChild);
469 this.engine.onInsert(this.namespaceId, newChild, parent, false);
470 };
471 BaseAnimationRenderer.prototype.insertBefore = function (parent, newChild, refChild) {
472 this.delegate.insertBefore(parent, newChild, refChild);
473 this.engine.onInsert(this.namespaceId, newChild, parent, true);
474 };
475 BaseAnimationRenderer.prototype.removeChild = function (parent, oldChild, isHostElement) {
476 this.engine.onRemove(this.namespaceId, oldChild, this.delegate, isHostElement);
477 };
478 BaseAnimationRenderer.prototype.selectRootElement = function (selectorOrNode, preserveContent) {
479 return this.delegate.selectRootElement(selectorOrNode, preserveContent);
480 };
481 BaseAnimationRenderer.prototype.parentNode = function (node) {
482 return this.delegate.parentNode(node);
483 };
484 BaseAnimationRenderer.prototype.nextSibling = function (node) {
485 return this.delegate.nextSibling(node);
486 };
487 BaseAnimationRenderer.prototype.setAttribute = function (el, name, value, namespace) {
488 this.delegate.setAttribute(el, name, value, namespace);
489 };
490 BaseAnimationRenderer.prototype.removeAttribute = function (el, name, namespace) {
491 this.delegate.removeAttribute(el, name, namespace);
492 };
493 BaseAnimationRenderer.prototype.addClass = function (el, name) {
494 this.delegate.addClass(el, name);
495 };
496 BaseAnimationRenderer.prototype.removeClass = function (el, name) {
497 this.delegate.removeClass(el, name);
498 };
499 BaseAnimationRenderer.prototype.setStyle = function (el, style, value, flags) {
500 this.delegate.setStyle(el, style, value, flags);
501 };
502 BaseAnimationRenderer.prototype.removeStyle = function (el, style, flags) {
503 this.delegate.removeStyle(el, style, flags);
504 };
505 BaseAnimationRenderer.prototype.setProperty = function (el, name, value) {
506 if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) {
507 this.disableAnimations(el, !!value);
508 }
509 else {
510 this.delegate.setProperty(el, name, value);
511 }
512 };
513 BaseAnimationRenderer.prototype.setValue = function (node, value) {
514 this.delegate.setValue(node, value);
515 };
516 BaseAnimationRenderer.prototype.listen = function (target, eventName, callback) {
517 return this.delegate.listen(target, eventName, callback);
518 };
519 BaseAnimationRenderer.prototype.disableAnimations = function (element, value) {
520 this.engine.disableAnimations(element, value);
521 };
522 return BaseAnimationRenderer;
523 }());
524 var AnimationRenderer = /** @class */ (function (_super) {
525 __extends(AnimationRenderer, _super);
526 function AnimationRenderer(factory, namespaceId, delegate, engine) {
527 var _this = _super.call(this, namespaceId, delegate, engine) || this;
528 _this.factory = factory;
529 _this.namespaceId = namespaceId;
530 return _this;
531 }
532 AnimationRenderer.prototype.setProperty = function (el, name, value) {
533 if (name.charAt(0) == ANIMATION_PREFIX) {
534 if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {
535 value = value === undefined ? true : !!value;
536 this.disableAnimations(el, value);
537 }
538 else {
539 this.engine.process(this.namespaceId, el, name.substr(1), value);
540 }
541 }
542 else {
543 this.delegate.setProperty(el, name, value);
544 }
545 };
546 AnimationRenderer.prototype.listen = function (target, eventName, callback) {
547 var _a;
548 var _this = this;
549 if (eventName.charAt(0) == ANIMATION_PREFIX) {
550 var element = resolveElementFromTarget(target);
551 var name_1 = eventName.substr(1);
552 var phase = '';
553 // @listener.phase is for trigger animation callbacks
554 // @@listener is for animation builder callbacks
555 if (name_1.charAt(0) != ANIMATION_PREFIX) {
556 _a = __read(parseTriggerCallbackName(name_1), 2), name_1 = _a[0], phase = _a[1];
557 }
558 return this.engine.listen(this.namespaceId, element, name_1, phase, function (event) {
559 var countId = event['_data'] || -1;
560 _this.factory.scheduleListenerCallback(countId, callback, event);
561 });
562 }
563 return this.delegate.listen(target, eventName, callback);
564 };
565 return AnimationRenderer;
566 }(BaseAnimationRenderer));
567 function resolveElementFromTarget(target) {
568 switch (target) {
569 case 'body':
570 return document.body;
571 case 'document':
572 return document;
573 case 'window':
574 return window;
575 default:
576 return target;
577 }
578 }
579 function parseTriggerCallbackName(triggerName) {
580 var dotIndex = triggerName.indexOf('.');
581 var trigger = triggerName.substring(0, dotIndex);
582 var phase = triggerName.substr(dotIndex + 1);
583 return [trigger, phase];
584 }
585
586 /**
587 * @license
588 * Copyright Google Inc. All Rights Reserved.
589 *
590 * Use of this source code is governed by an MIT-style license that can be
591 * found in the LICENSE file at https://angular.io/license
592 */
593 var InjectableAnimationEngine = /** @class */ (function (_super) {
594 __extends(InjectableAnimationEngine, _super);
595 function InjectableAnimationEngine(doc, driver, normalizer) {
596 return _super.call(this, doc.body, driver, normalizer) || this;
597 }
598 InjectableAnimationEngine = __decorate([
599 core.Injectable(),
600 __param(0, core.Inject(common.DOCUMENT)),
601 __metadata("design:paramtypes", [Object, browser.AnimationDriver, browser.ɵAnimationStyleNormalizer])
602 ], InjectableAnimationEngine);
603 return InjectableAnimationEngine;
604 }(browser.ɵAnimationEngine));
605 function instantiateSupportedAnimationDriver() {
606 return browser.ɵsupportsWebAnimations() ? new browser.ɵWebAnimationsDriver() : new browser.ɵCssKeyframesDriver();
607 }
608 function instantiateDefaultStyleNormalizer() {
609 return new browser.ɵWebAnimationsStyleNormalizer();
610 }
611 function instantiateRendererFactory(renderer, engine, zone) {
612 return new AnimationRendererFactory(renderer, engine, zone);
613 }
614 /**
615 * @publicApi
616 */
617 var ANIMATION_MODULE_TYPE = new core.InjectionToken('AnimationModuleType');
618 var SHARED_ANIMATION_PROVIDERS = [
619 { provide: animations.AnimationBuilder, useClass: BrowserAnimationBuilder },
620 { provide: browser.ɵAnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer },
621 { provide: browser.ɵAnimationEngine, useClass: InjectableAnimationEngine }, {
622 provide: core.RendererFactory2,
623 useFactory: instantiateRendererFactory,
624 deps: [platformBrowser.ɵDomRendererFactory2, browser.ɵAnimationEngine, core.NgZone]
625 }
626 ];
627 /**
628 * Separate providers from the actual module so that we can do a local modification in Google3 to
629 * include them in the BrowserModule.
630 */
631 var BROWSER_ANIMATIONS_PROVIDERS = __spread([
632 { provide: browser.AnimationDriver, useFactory: instantiateSupportedAnimationDriver },
633 { provide: ANIMATION_MODULE_TYPE, useValue: 'BrowserAnimations' }
634 ], SHARED_ANIMATION_PROVIDERS);
635 /**
636 * Separate providers from the actual module so that we can do a local modification in Google3 to
637 * include them in the BrowserTestingModule.
638 */
639 var BROWSER_NOOP_ANIMATIONS_PROVIDERS = __spread([
640 { provide: browser.AnimationDriver, useClass: browser.ɵNoopAnimationDriver },
641 { provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations' }
642 ], SHARED_ANIMATION_PROVIDERS);
643
644 /**
645 * Exports `BrowserModule` with additional [dependency-injection providers](guide/glossary#provider)
646 * for use with animations. See [Animations](guide/animations).
647 * @publicApi
648 */
649 var BrowserAnimationsModule = /** @class */ (function () {
650 function BrowserAnimationsModule() {
651 }
652 BrowserAnimationsModule = __decorate([
653 core.NgModule({
654 exports: [platformBrowser.BrowserModule],
655 providers: BROWSER_ANIMATIONS_PROVIDERS,
656 })
657 ], BrowserAnimationsModule);
658 return BrowserAnimationsModule;
659 }());
660 /**
661 * A null player that must be imported to allow disabling of animations.
662 * @publicApi
663 */
664 var NoopAnimationsModule = /** @class */ (function () {
665 function NoopAnimationsModule() {
666 }
667 NoopAnimationsModule = __decorate([
668 core.NgModule({
669 exports: [platformBrowser.BrowserModule],
670 providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS,
671 })
672 ], NoopAnimationsModule);
673 return NoopAnimationsModule;
674 }());
675
676 /**
677 * @license
678 * Copyright Google Inc. All Rights Reserved.
679 *
680 * Use of this source code is governed by an MIT-style license that can be
681 * found in the LICENSE file at https://angular.io/license
682 */
683
684 /**
685 * @license
686 * Copyright Google Inc. All Rights Reserved.
687 *
688 * Use of this source code is governed by an MIT-style license that can be
689 * found in the LICENSE file at https://angular.io/license
690 */
691
692 /**
693 * @license
694 * Copyright Google Inc. All Rights Reserved.
695 *
696 * Use of this source code is governed by an MIT-style license that can be
697 * found in the LICENSE file at https://angular.io/license
698 */
699
700 /**
701 * @license
702 * Copyright Google Inc. All Rights Reserved.
703 *
704 * Use of this source code is governed by an MIT-style license that can be
705 * found in the LICENSE file at https://angular.io/license
706 */
707
708 /**
709 * Generated bundle index. Do not edit.
710 */
711
712 exports.ANIMATION_MODULE_TYPE = ANIMATION_MODULE_TYPE;
713 exports.BrowserAnimationsModule = BrowserAnimationsModule;
714 exports.NoopAnimationsModule = NoopAnimationsModule;
715 exports.ɵAnimationRenderer = AnimationRenderer;
716 exports.ɵAnimationRendererFactory = AnimationRendererFactory;
717 exports.ɵBrowserAnimationBuilder = BrowserAnimationBuilder;
718 exports.ɵBrowserAnimationFactory = BrowserAnimationFactory;
719 exports.ɵInjectableAnimationEngine = InjectableAnimationEngine;
720 exports.ɵangular_packages_platform_browser_animations_animations_a = instantiateSupportedAnimationDriver;
721 exports.ɵangular_packages_platform_browser_animations_animations_b = instantiateDefaultStyleNormalizer;
722 exports.ɵangular_packages_platform_browser_animations_animations_c = instantiateRendererFactory;
723 exports.ɵangular_packages_platform_browser_animations_animations_d = BROWSER_ANIMATIONS_PROVIDERS;
724 exports.ɵangular_packages_platform_browser_animations_animations_e = BROWSER_NOOP_ANIMATIONS_PROVIDERS;
725 exports.ɵangular_packages_platform_browser_animations_animations_f = BaseAnimationRenderer;
726
727 Object.defineProperty(exports, '__esModule', { value: true });
728
729})));
730//# sourceMappingURL=platform-browser-animations.umd.js.map