bd33e4048264460ae5bad8a549eca577501782e3
[sdc/sdc-workflow-designer.git] /
1 /* tslint:disable:array-type member-access variable-name typedef
2  only-arrow-functions directive-class-suffix component-class-suffix
3  component-selector no-unnecessary-type-assertion arrow-parens*/
4 import {PositionStrategy} from './position-strategy';
5
6 /**
7  * Free position strategy for overlay without origin
8  * @author lingyi.zcs
9  */
10 export class FreePositionStrategy implements PositionStrategy {
11   private _wrapper: HTMLElement;
12   // private _cssPosition: string = '';
13   // private _top: string = '';
14   // private _left: string = '';
15   // private _width: string = '';
16   // private _height: string = '';
17
18   // cssPosition(value: string) {
19   //   this._cssPosition = value;
20   //   return this;
21   // }
22
23   // top(value: number | string): this {
24   //   this._top = this._toCssValue(value);
25   //   return this;
26   // }
27
28   // left(value: number | string): this {
29   //   this._left = this._toCssValue(value);
30   //   return this;
31   // }
32
33   // width(value: number | string): this {
34   //   this._width = this._toCssValue(value);
35   //   return this;
36   // }
37
38   // height(value: number | string): this {
39   //   this._height = this._toCssValue(value);
40   //   return this;
41   // }
42
43   /**
44    * Apply the position to the element. (NOTE: normally will triggered by
45    * scrolling)
46    * @docs-private
47    *
48    * @param element Element to which to apply the CSS.
49    * @returns Resolved when the styles have been applied.
50    */
51   apply(element: HTMLElement): void {
52         if (!this._wrapper) {
53                 this._wrapper = document.createElement('div');
54                 this._wrapper.classList.add('cdk-free-overlay-wrapper');
55                 element.parentNode.insertBefore(this._wrapper, element);
56                 this._wrapper.appendChild(element);
57
58       // // Initialized style once
59       // const style = element.style;
60       // style.position = this._cssPosition;
61       // style.top = this._top;
62       // style.left = this._left;
63       // style.width = this._width;
64       // style.height = this._height;
65         }
66
67     // TODO: do somethings while triggered (eg. by scrolling)
68   }
69
70   /**
71    * Removes the wrapper element from the DOM.
72    */
73   dispose(): void {
74         if (this._wrapper && this._wrapper.parentNode) {
75                 this._wrapper.parentNode.removeChild(this._wrapper);
76                 this._wrapper = null;
77         }
78   }
79
80   // private _toCssValue(value: number | string) {
81   //   return typeof value === 'number' ? value + 'px' : value;
82   // }
83 }