From 2f95f730dbca7b4ff48aa1b404625aa3b61e76e7 Mon Sep 17 00:00:00 2001 From: Michael Yoder Date: Fri, 5 Aug 2022 10:06:50 -0400 Subject: [PATCH] Fix for resizing north not correctly recalculating position. When resizing upwards, the position was not recalculated so the element would grow downward until the resize finished, then it would jump to the correct location. --- .../angular2gridster/src/lib/gridList/GridListItem.ts | 2 +- .../src/lib/gridster-item/gridster-item.component.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/projects/angular2gridster/src/lib/gridList/GridListItem.ts b/projects/angular2gridster/src/lib/gridList/GridListItem.ts index cccd4856..c7edfef8 100644 --- a/projects/angular2gridster/src/lib/gridList/GridListItem.ts +++ b/projects/angular2gridster/src/lib/gridList/GridListItem.ts @@ -269,7 +269,7 @@ export class GridListItem { this.itemComponent.positionX = position.left; this.itemComponent.positionY = position.top; - this.itemComponent.updateElemenetPosition(); + this.itemComponent.updateElementPosition(); } public calculatePosition(gridster?: GridsterService): {left: number, top: number} { diff --git a/projects/angular2gridster/src/lib/gridster-item/gridster-item.component.ts b/projects/angular2gridster/src/lib/gridster-item/gridster-item.component.ts index 6a440168..98af58b5 100644 --- a/projects/angular2gridster/src/lib/gridster-item/gridster-item.component.ts +++ b/projects/angular2gridster/src/lib/gridster-item/gridster-item.component.ts @@ -359,7 +359,7 @@ export class GridsterItemComponent implements OnInit, OnChanges, AfterViewInit, this.disableResizable(); } - updateElemenetPosition() { + updateElementPosition() { if (this.gridster.options.useCSSTransforms) { utils.setTransform(this.$element, {x: this._positionX, y: this._positionY}); } else { @@ -484,7 +484,7 @@ export class GridsterItemComponent implements OnInit, OnChanges, AfterViewInit, this.gridster.gridsterRect.top); this.positionX = (event.clientX - cursorToElementPosition.x - this.gridster.gridsterRect.left); - this.updateElemenetPosition(); + this.updateElementPosition(); this.gridster.onDrag(this.item); }); @@ -658,6 +658,7 @@ export class GridsterItemComponent implements OnInit, OnChanges, AfterViewInit, this.setMaxHeight('n', config); } else { this.positionY = config.position.y; + this.updateElementPosition(); this.$element.style.height = height + 'px'; } } @@ -672,7 +673,7 @@ export class GridsterItemComponent implements OnInit, OnChanges, AfterViewInit, this.setMaxWidth('w', config); } else { this.positionX = config.position.x; - this.updateElemenetPosition(); + this.updateElementPosition(); this.$element.style.width = width + 'px'; } } @@ -716,7 +717,7 @@ export class GridsterItemComponent implements OnInit, OnChanges, AfterViewInit, if (direction === 'w') { this.$element.style.width = (config.startData.minW * this.gridster.cellWidth) + 'px'; this.positionX = config.startData.maxX * this.gridster.cellWidth; - this.updateElemenetPosition(); + this.updateElementPosition(); } else { this.$element.style.width = (config.startData.minW * this.gridster.cellWidth) + 'px'; } @@ -737,7 +738,7 @@ export class GridsterItemComponent implements OnInit, OnChanges, AfterViewInit, if (direction === 'w') { this.$element.style.width = (config.startData.maxW * this.gridster.cellWidth) + 'px'; this.positionX = config.startData.minX * this.gridster.cellWidth; - this.updateElemenetPosition(); + this.updateElementPosition(); } else { this.$element.style.width = (config.startData.maxW * this.gridster.cellWidth) + 'px'; }