source: trip-planner-front/node_modules/@angular/cdk/esm2015/overlay/dispatchers/base-overlay-dispatcher.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.7 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { DOCUMENT } from '@angular/common';
9import { Inject, Injectable } from '@angular/core';
10import * as i0 from "@angular/core";
11import * as i1 from "@angular/common";
12/**
13 * Service for dispatching events that land on the body to appropriate overlay ref,
14 * if any. It maintains a list of attached overlays to determine best suited overlay based
15 * on event target and order of overlay opens.
16 */
17export class BaseOverlayDispatcher {
18 constructor(document) {
19 /** Currently attached overlays in the order they were attached. */
20 this._attachedOverlays = [];
21 this._document = document;
22 }
23 ngOnDestroy() {
24 this.detach();
25 }
26 /** Add a new overlay to the list of attached overlay refs. */
27 add(overlayRef) {
28 // Ensure that we don't get the same overlay multiple times.
29 this.remove(overlayRef);
30 this._attachedOverlays.push(overlayRef);
31 }
32 /** Remove an overlay from the list of attached overlay refs. */
33 remove(overlayRef) {
34 const index = this._attachedOverlays.indexOf(overlayRef);
35 if (index > -1) {
36 this._attachedOverlays.splice(index, 1);
37 }
38 // Remove the global listener once there are no more overlays.
39 if (this._attachedOverlays.length === 0) {
40 this.detach();
41 }
42 }
43}
44BaseOverlayDispatcher.ɵprov = i0.ɵɵdefineInjectable({ factory: function BaseOverlayDispatcher_Factory() { return new BaseOverlayDispatcher(i0.ɵɵinject(i1.DOCUMENT)); }, token: BaseOverlayDispatcher, providedIn: "root" });
45BaseOverlayDispatcher.decorators = [
46 { type: Injectable, args: [{ providedIn: 'root' },] }
47];
48BaseOverlayDispatcher.ctorParameters = () => [
49 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
50];
51//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJm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