Skip to content

Commit bf29ac2

Browse files
committed
fix(tile): Resize-end setting correct width/height after transition
1 parent afde020 commit bf29ac2

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/components/resize-container/resize-container.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export default class IgcResizeContainerComponent extends EventEmitterMixin<
9494
return this._mode;
9595
}
9696

97+
public setSize(width: number, height: number): void {
98+
this._controller.setSize(width, height);
99+
}
100+
97101
constructor() {
98102
super();
99103

src/components/resize-container/resize-controller.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ class ResizeController implements ReactiveController {
7272
this._activeRef = null;
7373
}
7474

75+
/** Assign the given width and height in pixels to the resize target of the controller. */
76+
public setSize(width: number, height: number): void {
77+
if (this._resizeTarget) {
78+
Object.assign(this._resizeTarget.style, {
79+
width: `${width}px`,
80+
height: `${height}px`,
81+
});
82+
}
83+
}
84+
7585
/** @internal */
7686
public hostConnected(): void {
7787
this._host.addEventListener('pointerdown', this);
@@ -144,9 +154,7 @@ class ResizeController implements ReactiveController {
144154
this._options.end?.call(this._host, parameters);
145155
this._state.current = parameters.state.current;
146156

147-
parameters.state.commit?.call(this._host) ??
148-
this._updatePosition(this._resizeTarget);
149-
157+
this._updatePosition(this._resizeTarget);
150158
this.dispose();
151159
}
152160

src/components/resize-container/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export type ResizeState = {
1212
deltaY: number;
1313
ghost: HTMLElement | null;
1414
trigger: HTMLElement | null;
15-
commit?: () => unknown;
1615
};
1716

1817
export type ResizeCallbackParams = {

src/components/tile-manager/tile.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,12 @@ export default class IgcTileComponent extends EventEmitterMixin<
461461
});
462462

463463
await transition?.finished;
464-
const updatedSize = this._resizeState.calculateResizedSize(
464+
465+
const { width, height } = this._resizeState.calculateResizedSize(
465466
this._cssContainer
466467
);
467468

468-
state.current.width = updatedSize.width;
469-
state.current.height = updatedSize.height;
470-
469+
this._resizeContainer?.setSize(width, height);
471470
this._setResizeState(false);
472471
}
473472

0 commit comments

Comments
 (0)