Skip to content

Commit 17d2dbd

Browse files
committed
fix: Do not show outline when tile resizing is disabled
perf: Drag positioning uses 3d transforms for improved view transition performance. Clamp coordinates to prevent subpixel blur.
1 parent 7b14a9c commit 17d2dbd

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

src/components/common/controllers/drag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import type { Ref } from 'lit/directives/ref.js';
77

88
import { getDefaultLayer } from '../../resize-container/default-ghost.js';
9-
import { findElementFromEventPath, getRoot } from '../util.js';
9+
import { findElementFromEventPath, getRoot, roundByDPR } from '../util.js';
1010

1111
type DragCallback = (parameters: DragCallbackParameters) => unknown;
1212
type DragCancelCallback = (state: DragState) => unknown;
@@ -381,7 +381,7 @@ class DragController implements ReactiveController {
381381
}
382382

383383
private _assignPosition(element: HTMLElement): void {
384-
element.style.transform = `translate(${this._state.position.x}px,${this._state.position.y}px)`;
384+
element.style.transform = `translate3d(${roundByDPR(this._state.position.x)}px,${roundByDPR(this._state.position.y)}px,0)`;
385385
}
386386

387387
private _createDragGhost(): void {

src/components/common/util.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,8 @@ export function getCenterPoint(element: Element) {
341341
y: top + height * 0.5,
342342
};
343343
}
344+
345+
export function roundByDPR(value: number): number {
346+
const dpr = globalThis.devicePixelRatio || 1;
347+
return Math.round(value * dpr) / dpr;
348+
}

src/components/popover/popover.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { property, query, queryAssignedElements } from 'lit/decorators.js';
1313

1414
import { watch } from '../common/decorators/watch.js';
1515
import { registerComponent } from '../common/definitions/register.js';
16-
import { getElementByIdFromRoot, isEmpty, isString } from '../common/util.js';
16+
import {
17+
getElementByIdFromRoot,
18+
isEmpty,
19+
isString,
20+
roundByDPR,
21+
} from '../common/util.js';
1722
import { styles } from './themes/light/popover.base.css.js';
1823

19-
function roundByDPR(value: number) {
20-
const dpr = globalThis.devicePixelRatio || 1;
21-
return Math.round(value * dpr) / dpr;
22-
}
23-
2424
/**
2525
* Describes the preferred placement of a toggle component.
2626
*/

src/components/tile-manager/tile.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,17 @@ export default class IgcTileComponent extends EventEmitterMixin<
499499
state.current
500500
);
501501

502-
const { transition } = startViewTransition(() => {
502+
await startViewTransition(() => {
503503
this.colSpan = colSpan;
504504
this.rowSpan = rowSpan;
505-
});
505+
}).transition?.updateCallbackDone;
506+
507+
// const { transition } = startViewTransition(() => {
508+
// this.colSpan = colSpan;
509+
// this.rowSpan = rowSpan;
510+
// });
506511

507-
await transition?.updateCallbackDone;
512+
// await transition?.updateCallbackDone;
508513

509514
// TODO:
510515
// const { width, height } = this._resizeState.calculateActualSize(
@@ -651,6 +656,9 @@ export default class IgcTileComponent extends EventEmitterMixin<
651656

652657
this._resizeContainer?.setSize(width, height);
653658

659+
const isEnabled = !this._resizeDisabled;
660+
const isActive = !this._resizeDisabled && this._resizeMode === 'always';
661+
654662
return html`
655663
<igc-resize
656664
part=${partNameMap({
@@ -661,8 +669,8 @@ export default class IgcTileComponent extends EventEmitterMixin<
661669
})}
662670
exportparts="trigger-side, trigger, trigger-bottom"
663671
mode="deferred"
664-
.enabled=${!this._resizeDisabled}
665-
?active=${this._resizeMode === 'always'}
672+
.enabled=${isEnabled}
673+
?active=${isActive}
666674
.ghostFactory=${this._createResizeGhost}
667675
@igcResizeStart=${this._handleResizeStart}
668676
@igcResize=${this._handleResize}

0 commit comments

Comments
 (0)