Skip to content

Commit 2f39071

Browse files
committed
use margin property
1 parent 9eb3979 commit 2f39071

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

packages/uui-popover-container/lib/uui-popover-container.element.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,6 @@ export class UUIPopoverContainerElement extends LitElement {
7474
this.removeEventListener('beforetoggle', this.#onBeforeToggle);
7575
}
7676

77-
#updatePadding = () => {
78-
const oppositeSides: Record<string, string> = {
79-
top: 'bottom',
80-
bottom: 'top',
81-
left: 'right',
82-
right: 'left',
83-
};
84-
85-
// find the side excluding start/end
86-
let side = this._actualPlacement.split('-')[0];
87-
// find the opposite side
88-
side = oppositeSides[side] || side;
89-
// capitalize the side
90-
side = side.charAt(0).toUpperCase() + side.slice(1);
91-
92-
const paddingSide = `padding${side}`;
93-
this.style.padding = '0';
94-
(this.style as any)[paddingSide] = `10px`;
95-
};
96-
9777
#onBeforeToggle = async (event: any) => {
9878
this.#targetElement = this.#findAncestorWithAttribute(
9979
this,
@@ -273,6 +253,26 @@ export class UUIPopoverContainerElement extends LitElement {
273253
this.style.opacity = '1';
274254
};
275255

256+
#updatePadding = () => {
257+
const oppositeSides: Record<string, string> = {
258+
top: 'bottom',
259+
bottom: 'top',
260+
left: 'right',
261+
right: 'left',
262+
};
263+
264+
// find the side excluding start/end
265+
let side = this._actualPlacement.split('-')[0];
266+
// find the opposite side
267+
side = oppositeSides[side] || side;
268+
// capitalize the side
269+
side = side.charAt(0).toUpperCase() + side.slice(1);
270+
271+
const paddingSide = `padding${side}`;
272+
this.style.padding = '0';
273+
(this.style as any)[paddingSide] = `${this.margin}px`;
274+
};
275+
276276
#flipPlacement() {
277277
const [direction, position] = this._actualPlacement.split('-');
278278
const oppositeDirection =

0 commit comments

Comments
 (0)