From c0ee2bd3128cb353f0094cb29c49f326a127bcb0 Mon Sep 17 00:00:00 2001 From: thenick775 Date: Sun, 15 Dec 2024 22:38:35 -0800 Subject: [PATCH] test: logging --- gbajs3/index.html | 2 +- gbajs3/src/components/screen/screen.tsx | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gbajs3/index.html b/gbajs3/index.html index cf5f49ca..49480428 100644 --- a/gbajs3/index.html +++ b/gbajs3/index.html @@ -5,7 +5,7 @@ { const { setCanvas } = useEmulatorContext(); const { areItemsDraggable } = useDragContext(); const { areItemsResizable } = useResizeContext(); - const { layouts, setLayout, hasSetLayout } = useLayoutContext(); + const { layouts, setLayout, hasSetLayout, clearLayouts } = useLayoutContext(); const screenWrapperXStart = isLargerThanPhone ? NavigationMenuWidth + 10 : 0; const screenWrapperYStart = isLargerThanPhone && !isMobileLandscape ? 15 : 0; const rndRef = useRef(); @@ -89,6 +89,19 @@ export const Screen = () => { useLayoutEffect(() => { if (layouts?.screen?.position || layouts?.screen?.size) return; + console.log( + 'window/screen', + window.innerWidth, + window.innerHeight, + screen.width, + screen.height, + document.documentElement.clientWidth, + document.documentElement.clientHeight + ); + + // const width = isMobileLandscape ? screen.height : screen.width; + // const height = isMobileLandscape ? screen.width : screen.height; + const x = Math.floor( window.innerWidth / 2 - (layouts?.screen?.initialBounds?.width ?? 0) / 2 ); @@ -96,8 +109,11 @@ export const Screen = () => { window.innerHeight / 2 - (layouts?.screen?.initialBounds?.height ?? 0) / 2 ); + console.log('x/y/isMobileLandscape', x, y, isMobileLandscape); + if (isMobileLandscape) rndRef?.current?.updatePosition({ x, y }); + clearLayouts(); setLayout('screen', { initialBounds: rndRef.current?.resizableElement?.current?.getBoundingClientRect()