@@ -12,6 +12,7 @@ export function useWindowFrame() {
1212 const containerInsetsRef = useRef < { left : number ; right : number ; top : number ; bottom : number } > ( { left : 0 , right : 0 , top : 0 , bottom : 0 } ) ;
1313
1414 const framePosRef = useRef < { x : number ; y : number } > ( { x : 0 , y : 0 } ) ;
15+ const previousFramePosRef = useRef < { x : number ; y : number } > ( { x : 0 , y : 0 } ) ;
1516 const rafRef = useRef < number | null > ( null ) ;
1617 const isMaximizedRef = useRef ( false ) ;
1718
@@ -26,8 +27,11 @@ export function useWindowFrame() {
2627 const applyTransform = useCallback ( ( p : { x : number ; y : number } ) => {
2728 const el = frameRef . current ;
2829 if ( ! el ) return ;
29- const scale = isMaximizedRef . current ? 1.08 : 1.0 ;
30- el . style . transform = `translate(${ p . x } px, ${ p . y } px) scale(${ scale } )` ;
30+ if ( isMaximizedRef . current ) {
31+ el . style . transform = "translate(0px, 0px)" ;
32+ return ;
33+ }
34+ el . style . transform = `translate(${ p . x } px, ${ p . y } px)` ;
3135 } , [ ] ) ;
3236
3337 const getBounds = useCallback ( ( ) => {
@@ -36,9 +40,8 @@ export function useWindowFrame() {
3640 // Respect actual container padding as the safe space, fallback to 16px
3741 const padX = Math . max ( 16 , Math . min ( containerInsetsRef . current . left , containerInsetsRef . current . right ) ) ;
3842 const padY = Math . max ( 16 , Math . min ( containerInsetsRef . current . top , containerInsetsRef . current . bottom ) ) ;
39- const scale = isMaximizedRef . current ? 1.08 : 1.0 ;
40- const width = ( frameSizeRef . current . width || Math . min ( cw , 800 ) ) * scale ;
41- const height = ( frameSizeRef . current . height || Math . min ( ch , 500 ) ) * scale ;
43+ const width = frameSizeRef . current . width || Math . min ( cw , 800 ) ;
44+ const height = frameSizeRef . current . height || Math . min ( ch , 500 ) ;
4245 const halfW = Math . min ( width , cw ) / 2 ;
4346 const halfH = Math . min ( height , ch ) / 2 ;
4447 const maxX = Math . max ( 0 , cw / 2 - halfW - padX ) ;
@@ -114,6 +117,9 @@ export function useWindowFrame() {
114117 const onDragPointerDown = ( e : React . PointerEvent < HTMLDivElement > ) => {
115118 if ( e . button !== 0 ) return ;
116119 const target = e . target as HTMLElement | null ;
120+ if ( isMaximizedRef . current ) {
121+ return ;
122+ }
117123 if ( target && target . closest ( "button, a, [data-action], [data-no-drag]" ) ) {
118124 return ;
119125 }
@@ -192,11 +198,19 @@ export function useWindowFrame() {
192198 applyTransform ( { x : 0 , y : 0 } ) ;
193199 setIsClosed ( true ) ;
194200 } else if ( action === "toggle-maximize" ) {
195- isMaximizedRef . current = ! isMaximizedRef . current ;
196- setIsMaximized ( isMaximizedRef . current ) ;
197- const clamped = clampToViewport ( framePosRef . current . x , framePosRef . current . y ) ;
198- framePosRef . current = clamped ;
199- applyTransform ( clamped ) ;
201+ if ( ! isMaximizedRef . current ) {
202+ previousFramePosRef . current = { ...framePosRef . current } ;
203+ isMaximizedRef . current = true ;
204+ setIsMaximized ( true ) ;
205+ framePosRef . current = { x : 0 , y : 0 } ;
206+ applyTransform ( { x : 0 , y : 0 } ) ;
207+ } else {
208+ isMaximizedRef . current = false ;
209+ setIsMaximized ( false ) ;
210+ const restored = clampToViewport ( previousFramePosRef . current . x , previousFramePosRef . current . y ) ;
211+ framePosRef . current = restored ;
212+ applyTransform ( restored ) ;
213+ }
200214 }
201215 } ,
202216 [ applyTransform , clampToViewport ]
@@ -224,4 +238,3 @@ export function useWindowFrame() {
224238 } as const ;
225239}
226240
227-
0 commit comments