source: trip-planner-front/node_modules/@angular/cdk/esm2015/scrolling/viewport-ruler.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 19.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 { Platform } from '@angular/cdk/platform';
9import { Injectable, NgZone, Optional, Inject } from '@angular/core';
10import { Subject } from 'rxjs';
11import { auditTime } from 'rxjs/operators';
12import { DOCUMENT } from '@angular/common';
13import * as i0 from "@angular/core";
14import * as i1 from "@angular/cdk/platform";
15import * as i2 from "@angular/common";
16/** Time in ms to throttle the resize events by default. */
17export const DEFAULT_RESIZE_TIME = 20;
18/**
19 * Simple utility for getting the bounds of the browser viewport.
20 * @docs-private
21 */
22export class ViewportRuler {
23 constructor(_platform, ngZone, document) {
24 this._platform = _platform;
25 /** Stream of viewport change events. */
26 this._change = new Subject();
27 /** Event listener that will be used to handle the viewport change events. */
28 this._changeListener = (event) => {
29 this._change.next(event);
30 };
31 this._document = document;
32 ngZone.runOutsideAngular(() => {
33 if (_platform.isBrowser) {
34 const window = this._getWindow();
35 // Note that bind the events ourselves, rather than going through something like RxJS's
36 // `fromEvent` so that we can ensure that they're bound outside of the NgZone.
37 window.addEventListener('resize', this._changeListener);
38 window.addEventListener('orientationchange', this._changeListener);
39 }
40 // Clear the cached position so that the viewport is re-measured next time it is required.
41 // We don't need to keep track of the subscription, because it is completed on destroy.
42 this.change().subscribe(() => this._viewportSize = null);
43 });
44 }
45 ngOnDestroy() {
46 if (this._platform.isBrowser) {
47 const window = this._getWindow();
48 window.removeEventListener('resize', this._changeListener);
49 window.removeEventListener('orientationchange', this._changeListener);
50 }
51 this._change.complete();
52 }
53 /** Returns the viewport's width and height. */
54 getViewportSize() {
55 if (!this._viewportSize) {
56 this._updateViewportSize();
57 }
58 const output = { width: this._viewportSize.width, height: this._viewportSize.height };
59 // If we're not on a browser, don't cache the size since it'll be mocked out anyway.
60 if (!this._platform.isBrowser) {
61 this._viewportSize = null;
62 }
63 return output;
64 }
65 /** Gets a ClientRect for the viewport's bounds. */
66 getViewportRect() {
67 // Use the document element's bounding rect rather than the window scroll properties
68 // (e.g. pageYOffset, scrollY) due to in issue in Chrome and IE where window scroll
69 // properties and client coordinates (boundingClientRect, clientX/Y, etc.) are in different
70 // conceptual viewports. Under most circumstances these viewports are equivalent, but they
71 // can disagree when the page is pinch-zoomed (on devices that support touch).
72 // See https://bugs.chromium.org/p/chromium/issues/detail?id=489206#c4
73 // We use the documentElement instead of the body because, by default (without a css reset)
74 // browsers typically give the document body an 8px margin, which is not included in
75 // getBoundingClientRect().
76 const scrollPosition = this.getViewportScrollPosition();
77 const { width, height } = this.getViewportSize();
78 return {
79 top: scrollPosition.top,
80 left: scrollPosition.left,
81 bottom: scrollPosition.top + height,
82 right: scrollPosition.left + width,
83 height,
84 width,
85 };
86 }
87 /** Gets the (top, left) scroll position of the viewport. */
88 getViewportScrollPosition() {
89 // While we can get a reference to the fake document
90 // during SSR, it doesn't have getBoundingClientRect.
91 if (!this._platform.isBrowser) {
92 return { top: 0, left: 0 };
93 }
94 // The top-left-corner of the viewport is determined by the scroll position of the document
95 // body, normally just (scrollLeft, scrollTop). However, Chrome and Firefox disagree about
96 // whether `document.body` or `document.documentElement` is the scrolled element, so reading
97 // `scrollTop` and `scrollLeft` is inconsistent. However, using the bounding rect of
98 // `document.documentElement` works consistently, where the `top` and `left` values will
99 // equal negative the scroll position.
100 const document = this._document;
101 const window = this._getWindow();
102 const documentElement = document.documentElement;
103 const documentRect = documentElement.getBoundingClientRect();
104 const top = -documentRect.top || document.body.scrollTop || window.scrollY ||
105 documentElement.scrollTop || 0;
106 const left = -documentRect.left || document.body.scrollLeft || window.scrollX ||
107 documentElement.scrollLeft || 0;
108 return { top, left };
109 }
110 /**
111 * Returns a stream that emits whenever the size of the viewport changes.
112 * This stream emits outside of the Angular zone.
113 * @param throttleTime Time in milliseconds to throttle the stream.
114 */
115 change(throttleTime = DEFAULT_RESIZE_TIME) {
116 return throttleTime > 0 ? this._change.pipe(auditTime(throttleTime)) : this._change;
117 }
118 /** Use defaultView of injected document if available or fallback to global window reference */
119 _getWindow() {
120 return this._document.defaultView || window;
121 }
122 /** Updates the cached viewport size. */
123 _updateViewportSize() {
124 const window = this._getWindow();
125 this._viewportSize = this._platform.isBrowser ?
126 { width: window.innerWidth, height: window.innerHeight } :
127 { width: 0, height: 0 };
128 }
129}
130ViewportRuler.ɵprov = i0.ɵɵdefineInjectable({ factory: function ViewportRuler_Factory() { return new ViewportRuler(i0.ɵɵinject(i1.Platform), i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i2.DOCUMENT, 8)); }, token: ViewportRuler, providedIn: "root" });
131ViewportRuler.decorators = [
132 { type: Injectable, args: [{ providedIn: 'root' },] }
133];
134ViewportRuler.ctorParameters = () => [
135 { type: Platform },
136 { type: NgZone },
137 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
138];
139//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmlld3BvcnQtcnVsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3Njcm9sbGluZy92aWV3cG9ydC1ydWxlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7QUFDL0MsT0FBTyxFQUFDLFVBQVUsRUFBRSxNQUFNLEVBQWEsUUFBUSxFQUFFLE1BQU0sRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUM5RSxPQUFPLEVBQWEsT0FBTyxFQUFDLE1BQU0sTUFBTSxDQUFDO0FBQ3pDLE9BQU8sRUFBQyxTQU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