import { DirTypes, GridType } from './gridsterConfig.interface'; export class GridsterRenderer { constructor(gridster) { this.gridster = gridster; /** * Caches the last grid column styles. * This improves the grid responsiveness by caching and reusing the last style object instead of creating a new one. */ this.lastGridColumnStyles = {}; /** * Caches the last grid column styles. * This improves the grid responsiveness by caching and reusing the last style object instead of creating a new one. */ this.lastGridRowStyles = {}; } destroy() { this.gridster = null; } updateItem(el, item, renderer) { if (this.gridster.mobile) { this.clearCellPosition(renderer, el); if (this.gridster.$options.keepFixedHeightInMobile) { renderer.setStyle(el, 'height', (item.rows - 1) * this.gridster.$options.margin + item.rows * this.gridster.$options.fixedRowHeight + 'px'); } else { renderer.setStyle(el, 'height', (item.rows * this.gridster.curWidth) / item.cols + 'px'); } if (this.gridster.$options.keepFixedWidthInMobile) { renderer.setStyle(el, 'width', this.gridster.$options.fixedColWidth + 'px'); } else { renderer.setStyle(el, 'width', ''); } renderer.setStyle(el, 'margin-bottom', this.gridster.$options.margin + 'px'); renderer.setStyle(el, DirTypes.LTR ? 'margin-right' : 'margin-left', ''); } else { const x = Math.round(this.gridster.curColWidth * item.x); const y = Math.round(this.gridster.curRowHeight * item.y); const width = this.gridster.curColWidth * item.cols - this.gridster.$options.margin; const height = this.gridster.curRowHeight * item.rows - this.gridster.$options.margin; // set the cell style this.setCellPosition(renderer, el, x, y); renderer.setStyle(el, 'width', width + 'px'); renderer.setStyle(el, 'height', height + 'px'); let marginBottom = null; let marginRight = null; if (this.gridster.$options.outerMargin) { if (this.gridster.rows === item.rows + item.y) { if (this.gridster.$options.outerMarginBottom !== null) { marginBottom = this.gridster.$options.outerMarginBottom + 'px'; } else { marginBottom = this.gridster.$options.margin + 'px'; } } if (this.gridster.columns === item.cols + item.x) { if (this.gridster.$options.outerMarginBottom !== null) { marginRight = this.gridster.$options.outerMarginRight + 'px'; } else { marginRight = this.gridster.$options.margin + 'px'; } } } renderer.setStyle(el, 'margin-bottom', marginBottom); renderer.setStyle(el, DirTypes.LTR ? 'margin-right' : 'margin-left', marginRight); } } updateGridster() { let addClass = ''; let removeClass1 = ''; let removeClass2 = ''; let removeClass3 = ''; if (this.gridster.$options.gridType === GridType.Fit) { addClass = GridType.Fit; removeClass1 = GridType.ScrollVertical; removeClass2 = GridType.ScrollHorizontal; removeClass3 = GridType.Fixed; } else if (this.gridster.$options.gridType === GridType.ScrollVertical) { this.gridster.curRowHeight = this.gridster.curColWidth * this.gridster.$options.rowHeightRatio; addClass = GridType.ScrollVertical; removeClass1 = GridType.Fit; removeClass2 = GridType.ScrollHorizontal; removeClass3 = GridType.Fixed; } else if (this.gridster.$options.gridType === GridType.ScrollHorizontal) { const widthRatio = this.gridster.$options.rowHeightRatio; const calWidthRatio = widthRatio >= 1 ? widthRatio : widthRatio + 1; this.gridster.curColWidth = this.gridster.curRowHeight * calWidthRatio; addClass = GridType.ScrollHorizontal; removeClass1 = GridType.Fit; removeClass2 = GridType.ScrollVertical; removeClass3 = GridType.Fixed; } else if (this.gridster.$options.gridType === GridType.Fixed) { this.gridster.curColWidth = this.gridster.$options.fixedColWidth + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin); this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin); addClass = GridType.Fixed; removeClass1 = GridType.Fit; removeClass2 = GridType.ScrollVertical; removeClass3 = GridType.ScrollHorizontal; } else if (this.gridster.$options.gridType === GridType.VerticalFixed) { this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin); addClass = GridType.ScrollVertical; removeClass1 = GridType.Fit; removeClass2 = GridType.ScrollHorizontal; removeClass3 = GridType.Fixed; } else if (this.gridster.$options.gridType === GridType.HorizontalFixed) { this.gridster.curColWidth = this.gridster.$options.fixedColWidth + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin); addClass = GridType.ScrollHorizontal; removeClass1 = GridType.Fit; removeClass2 = GridType.ScrollVertical; removeClass3 = GridType.Fixed; } if (this.gridster.mobile || (this.gridster.$options.setGridSize && this.gridster.$options.gridType !== GridType.Fit)) { this.gridster.renderer.removeClass(this.gridster.el, addClass); } else { this.gridster.renderer.addClass(this.gridster.el, addClass); } this.gridster.renderer.removeClass(this.gridster.el, removeClass1); this.gridster.renderer.removeClass(this.gridster.el, removeClass2); this.gridster.renderer.removeClass(this.gridster.el, removeClass3); } getGridColumnStyle(i) { // generates the new style const newPos = { left: this.gridster.curColWidth * i, width: this.gridster.curColWidth - this.gridster.$options.margin, height: this.gridster.gridRows.length * this.gridster.curRowHeight - this.gridster.$options.margin, style: {} }; newPos.style = { ...this.getLeftPosition(newPos.left), width: newPos.width + 'px', height: newPos.height + 'px' }; // use the last cached style if it has same values as the generated one const last = this.lastGridColumnStyles[i]; if (last && last.left === newPos.left && last.width === newPos.width && last.height === newPos.height) { return last.style; } // cache and set new style this.lastGridColumnStyles[i] = newPos; return newPos.style; } getGridRowStyle(i) { // generates the new style const newPos = { top: this.gridster.curRowHeight * i, width: this.gridster.gridColumns.length * this.gridster.curColWidth + this.gridster.$options.margin, height: this.gridster.curRowHeight - this.gridster.$options.margin, style: {} }; newPos.style = { ...this.getTopPosition(newPos.top), width: newPos.width + 'px', height: newPos.height + 'px' }; // use the last cached style if it has same values as the generated one const last = this.lastGridRowStyles[i]; if (last && last.top === newPos.top && last.width === newPos.width && last.height === newPos.height) { return last.style; } // cache and set new style this.lastGridRowStyles[i] = newPos; return newPos.style; } getLeftPosition(d) { const dPosition = this.gridster.$options.dirType === DirTypes.RTL ? -d : d; if (this.gridster.$options.useTransformPositioning) { return { transform: 'translateX(' + dPosition + 'px)' }; } else { return { left: this.getLeftMargin() + dPosition + 'px' }; } } getTopPosition(d) { if (this.gridster.$options.useTransformPositioning) { return { transform: 'translateY(' + d + 'px)' }; } else { return { top: this.getTopMargin() + d + 'px' }; } } clearCellPosition(renderer, el) { if (this.gridster.$options.useTransformPositioning) { renderer.setStyle(el, 'transform', ''); } else { renderer.setStyle(el, 'top', ''); renderer.setStyle(el, 'left', ''); } } setCellPosition(renderer, el, x, y) { const xPosition = this.gridster.$options.dirType === DirTypes.RTL ? -x : x; if (this.gridster.$options.useTransformPositioning) { const transform = 'translate3d(' + xPosition + 'px, ' + y + 'px, 0)'; renderer.setStyle(el, 'transform', transform); } else { renderer.setStyle(el, 'left', this.getLeftMargin() + xPosition + 'px'); renderer.setStyle(el, 'top', this.getTopMargin() + y + 'px'); } } getLeftMargin() { if (this.gridster.$options.outerMargin) { if (this.gridster.$options.outerMarginLeft !== null) { return this.gridster.$options.outerMarginLeft; } else { return this.gridster.$options.margin; } } else { return 0; } } getTopMargin() { if (this.gridster.$options.outerMargin) { if (this.gridster.$options.outerMarginTop !== null) { return this.gridster.$options.outerMarginTop; } else { return this.gridster.$options.margin; } } else { return 0; } } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZHN0ZXJSZW5kZXJlci5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvYW5ndWxhci1ncmlkc3RlcjIvc3JjL2xpYi9ncmlkc3RlclJlbmRlcmVyLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUFFLFFBQVEsRUFBRSxRQUFRLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQVFoRSxNQUFNLE9BQU8sZ0JBQWdCO0lBYTNCLFlBQW9CLFFBQW9DO1FBQXBDLGFBQVEsR0FBUixRQUFRLENBQTRCO1FBWnhEOzs7V0FHRztRQUNLLHlCQUFvQixHQUEwQyxFQUFFLENBQUM7UUFFekU7OztXQUdHO1FBQ0ssc0JBQWlCLEdBQXVDLEVBQUUsQ0FBQztJQUVSLENBQUM7SUFFNUQsT0FBTztRQUNMLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSyxDQUFDO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