Skip to content

Commit 845ac0c

Browse files
committed
Adjust main container when docking in wrapper mode
- Add applyMainContainerMargin() to adjust main container position/size - Add restoreMainContainer() to restore main container to fullscreen - Modify applyBodyMargin() to also handle main container in wrapper mode - Modify restoreBodyMargins() to also restore main container in wrapper mode This ensures docking/undocking, expand/collapse, and resize operations properly adjust the main iframe container in wrapper mode.
1 parent 26c0636 commit 845ac0c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

src/ServiceInjector.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export class ServiceInjector {
234234

235235
/**
236236
* Apply a margin to the body element on a specific side.
237+
* In wrapper mode, also adjusts the main container.
237238
* @param side - Which side to apply margin to
238239
* @param size - The margin size (e.g., '440px')
239240
*/
@@ -258,12 +259,23 @@ export class ServiceInjector {
258259
body.style.marginBottom = size;
259260
break;
260261
}
262+
263+
// Also adjust main container in wrapper mode
264+
if (this.config.wm) {
265+
this.applyMainContainerMargin(side, size);
266+
}
261267
}
262268

263269
/**
264270
* Restore body margins to their original values.
271+
* In wrapper mode, also restores the main container to fullscreen.
265272
*/
266273
private restoreBodyMargins(): void {
274+
// Restore main container in wrapper mode
275+
if (this.config.wm) {
276+
this.restoreMainContainer();
277+
}
278+
267279
if (!this.state.originalBodyMargin) return;
268280

269281
const body = document.body;
@@ -286,6 +298,58 @@ export class ServiceInjector {
286298
this.state.originalBodyMargin = null;
287299
}
288300

301+
/**
302+
* Adjust main container position/size for docking (wrapper mode only).
303+
* @param side - Which side the window is docked to
304+
* @param size - The size of the docked window (e.g., '440px')
305+
*/
306+
private applyMainContainerMargin(side: DockSide, size: string): void {
307+
const container = this.state.mainContainer;
308+
if (!container) return;
309+
310+
const duration = this.config.a;
311+
container.style.transition = `all ${duration}ms ease-in-out`;
312+
313+
switch (side) {
314+
case 'left':
315+
container.style.left = size;
316+
container.style.width = `calc(100% - ${size})`;
317+
break;
318+
case 'right':
319+
container.style.left = '0';
320+
container.style.width = `calc(100% - ${size})`;
321+
break;
322+
case 'top':
323+
container.style.top = size;
324+
container.style.height = `calc(100% - ${size})`;
325+
break;
326+
case 'bottom':
327+
container.style.top = '0';
328+
container.style.height = `calc(100% - ${size})`;
329+
break;
330+
}
331+
}
332+
333+
/**
334+
* Restore main container to fullscreen (wrapper mode only).
335+
*/
336+
private restoreMainContainer(): void {
337+
const container = this.state.mainContainer;
338+
if (!container) return;
339+
340+
const duration = this.config.a;
341+
container.style.transition = `all ${duration}ms ease-in-out`;
342+
container.style.top = '0';
343+
container.style.left = '0';
344+
container.style.width = '100%';
345+
container.style.height = '100%';
346+
347+
// Clear transition after animation completes
348+
setTimeout(() => {
349+
container.style.transition = '';
350+
}, duration);
351+
}
352+
289353
/**
290354
* Show dock preview overlay for a specific side.
291355
* @param side - The side to show the preview for

0 commit comments

Comments
 (0)