UNPKG

angular-gridster2

Version:
52 lines (51 loc) 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var gridster_component_1 = require("./gridster.component"); var GridsterPreviewComponent = (function () { function GridsterPreviewComponent(el, gridster, renderer) { this.renderer = renderer; this.el = el.nativeElement; this.gridster = gridster; this.gridster.previewStyle = this.previewStyle.bind(this); } GridsterPreviewComponent.prototype.ngOnDestroy = function () { delete this.el; delete this.gridster.previewStyle; delete this.gridster; }; GridsterPreviewComponent.prototype.previewStyle = function () { if (!this.gridster.movingItem) { this.renderer.setStyle(this.el, 'display', 'none'); } else { var margin = 0; var curRowHeight = this.gridster.curRowHeight; var curColWidth = this.gridster.curColWidth; if (this.gridster.$options.outerMargin) { margin = this.gridster.$options.margin; } this.renderer.setStyle(this.el, 'display', 'block'); this.renderer.setStyle(this.el, 'height', (this.gridster.movingItem.rows * curRowHeight - margin) + 'px'); this.renderer.setStyle(this.el, 'width', (this.gridster.movingItem.cols * curColWidth - margin) + 'px'); this.renderer.setStyle(this.el, 'top', (this.gridster.movingItem.y * curRowHeight + margin) + 'px'); this.renderer.setStyle(this.el, 'left', (this.gridster.movingItem.x * curColWidth + margin) + 'px'); this.renderer.setStyle(this.el, 'marginBottom', margin + 'px'); } }; GridsterPreviewComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'gridster-preview', template: '', styles: [":host { background: rgba(0, 0, 0, 0.15); position: absolute; }"] },] }, ]; /** @nocollapse */ GridsterPreviewComponent.ctorParameters = function () { return [ { type: core_1.ElementRef, }, { type: gridster_component_1.GridsterComponent, decorators: [{ type: core_1.Host },] }, { type: core_1.Renderer2, }, ]; }; return GridsterPreviewComponent; }()); exports.GridsterPreviewComponent = GridsterPreviewComponent;