Skip to content

Commit e6d1c18

Browse files
committed
remove:console.log
refactor:alignment-logic-to-use-switch-statement
1 parent 544b7e5 commit e6d1c18

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/components/modules/toolbar/inline.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
7676
// Get the value from the config
7777
this.align = config.alignInlineToolbar ?? 'left';
7878

79-
console.log(this.align);
80-
8179
window.requestIdleCallback(() => {
8280
this.make();
8381
}, { timeout: 2000 });
@@ -232,13 +230,17 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
232230

233231
let newX: number;
234232

235-
// Calculate x based on alignment
236-
if (this.align === 'left') {
237-
newX = selectionRect.x - wrapperOffset.x;
238-
} else if (this.align === 'right') {
239-
newX = selectionRect.x + selectionRect.width - popoverWidth - wrapperOffset.x;
240-
} else { // center (default)
241-
newX = selectionRect.x + selectionRect.width / 2 - popoverWidth / 2 - wrapperOffset.x;
233+
switch (this.align) {
234+
default:
235+
case 'left':
236+
newX = selectionRect.x - wrapperOffset.x;
237+
break;
238+
case 'right':
239+
newX = selectionRect.x + selectionRect.width - popoverWidth - wrapperOffset.x;
240+
break;
241+
case 'center':
242+
newX = selectionRect.x + selectionRect.width / 2 - popoverWidth / 2 - wrapperOffset.x;
243+
break;
242244
}
243245

244246
const newCoords = {

0 commit comments

Comments
 (0)