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';
7 * Free position strategy for overlay without origin
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 = '';
18 // cssPosition(value: string) {
19 // this._cssPosition = value;
23 // top(value: number | string): this {
24 // this._top = this._toCssValue(value);
28 // left(value: number | string): this {
29 // this._left = this._toCssValue(value);
33 // width(value: number | string): this {
34 // this._width = this._toCssValue(value);
38 // height(value: number | string): this {
39 // this._height = this._toCssValue(value);
44 * Apply the position to the element. (NOTE: normally will triggered by
48 * @param element Element to which to apply the CSS.
49 * @returns Resolved when the styles have been applied.
51 apply(element: HTMLElement): void {
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);
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;
67 // TODO: do somethings while triggered (eg. by scrolling)
71 * Removes the wrapper element from the DOM.
74 if (this._wrapper && this._wrapper.parentNode) {
75 this._wrapper.parentNode.removeChild(this._wrapper);
80 // private _toCssValue(value: number | string) {
81 // return typeof value === 'number' ? value + 'px' : value;