1 | import { applyCssTransform } from '@angular2-material/core';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export var GlobalPositionStrategy = (function () {
|
7 | function GlobalPositionStrategy() {
|
8 | this._cssPosition = 'absolute';
|
9 | this._top = '';
|
10 | this._bottom = '';
|
11 | this._left = '';
|
12 | this._right = '';
|
13 |
|
14 | this._translateX = [];
|
15 |
|
16 | this._translateY = [];
|
17 | }
|
18 |
|
19 | GlobalPositionStrategy.prototype.fixed = function () {
|
20 | this._cssPosition = 'fixed';
|
21 | return this;
|
22 | };
|
23 |
|
24 | GlobalPositionStrategy.prototype.absolute = function () {
|
25 | this._cssPosition = 'absolute';
|
26 | return this;
|
27 | };
|
28 |
|
29 | GlobalPositionStrategy.prototype.top = function (value) {
|
30 | this._bottom = '';
|
31 | this._translateY = [];
|
32 | this._top = value;
|
33 | return this;
|
34 | };
|
35 |
|
36 | GlobalPositionStrategy.prototype.left = function (value) {
|
37 | this._right = '';
|
38 | this._translateX = [];
|
39 | this._left = value;
|
40 | return this;
|
41 | };
|
42 |
|
43 | GlobalPositionStrategy.prototype.bottom = function (value) {
|
44 | this._top = '';
|
45 | this._translateY = [];
|
46 | this._bottom = value;
|
47 | return this;
|
48 | };
|
49 |
|
50 | GlobalPositionStrategy.prototype.right = function (value) {
|
51 | this._left = '';
|
52 | this._translateX = [];
|
53 | this._right = value;
|
54 | return this;
|
55 | };
|
56 | |
57 |
|
58 |
|
59 |
|
60 | GlobalPositionStrategy.prototype.centerHorizontally = function (offset) {
|
61 | if (offset === void 0) { offset = '0px'; }
|
62 | this._left = '50%';
|
63 | this._right = '';
|
64 | this._translateX = ['-50%', offset];
|
65 | return this;
|
66 | };
|
67 | |
68 |
|
69 |
|
70 |
|
71 | GlobalPositionStrategy.prototype.centerVertically = function (offset) {
|
72 | if (offset === void 0) { offset = '0px'; }
|
73 | this._top = '50%';
|
74 | this._bottom = '';
|
75 | this._translateY = ['-50%', offset];
|
76 | return this;
|
77 | };
|
78 | |
79 |
|
80 |
|
81 |
|
82 | GlobalPositionStrategy.prototype.apply = function (element) {
|
83 | element.style.position = this._cssPosition;
|
84 | element.style.top = this._top;
|
85 | element.style.left = this._left;
|
86 | element.style.bottom = this._bottom;
|
87 | element.style.right = this._right;
|
88 |
|
89 |
|
90 | var tranlateX = this._reduceTranslateValues('translateX', this._translateX);
|
91 | var translateY = this._reduceTranslateValues('translateY', this._translateY);
|
92 | applyCssTransform(element, tranlateX + " " + translateY);
|
93 | return Promise.resolve(null);
|
94 | };
|
95 |
|
96 | GlobalPositionStrategy.prototype._reduceTranslateValues = function (translateFn, values) {
|
97 | return values.map(function (t) { return (translateFn + "(" + t + ")"); }).join(' ');
|
98 | };
|
99 | return GlobalPositionStrategy;
|
100 | }());
|
101 |
|
102 |
|