feat: maximize -> full viewport + center-top; restore -> center behavior
This commit is contained in:
1 parent
e65db88011
commit
534149991e
1 file changed
+20
-8
+20
-8
@@ -196,17 +196,29 @@ function Plugin () {
|
||||
}, [])
|
||||
|
||||
function toggleWindowSize () {
|
||||
// "Maximize" targets the visible viewport geometry (maxViewport = bounds*zoom,
|
||||
// without subtracting header/frame). Figma clamps the request to its real window
|
||||
// limit (depends on whether Figma UI is hidden). The real size is then measured
|
||||
// via the iframe (window.innerWidth/Height) and shown as lastSize/gaps.
|
||||
const max = windowInfo != null ? windowInfo.maxViewport : { width: 1920, height: 1080 }
|
||||
const isMaximized =
|
||||
currentWindowSize.width >= max.width && currentWindowSize.height >= max.height
|
||||
const next = isMaximized ? { ...MIN_WINDOW_SIZE } : { ...max }
|
||||
setCurrentWindowSize(next)
|
||||
emit('RESIZE_WINDOW', next)
|
||||
refreshInfo()
|
||||
if (!isMaximized) {
|
||||
// Maximize: stretch to the full available viewport, then pin to center-top.
|
||||
setCurrentWindowSize({ ...max })
|
||||
emit('RESIZE_WINDOW', { ...max })
|
||||
// After Figma applies the resize (and clamps to its real limit), reposition to
|
||||
// center-top from the REAL rendered size (read from the iframe).
|
||||
requestAnimationFrame(function () {
|
||||
requestAnimationFrame(function () {
|
||||
emit('DOCK_REFINE', {
|
||||
position: 'top-center',
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight
|
||||
})
|
||||
refreshInfo()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// Restore: behave exactly like the Center button (50% viewport, centered).
|
||||
dockWindow('center')
|
||||
}
|
||||
}
|
||||
|
||||
// 9 dock positions: 4 corners + 4 edges + center.
|
||||
|
||||
Reference in new issue
Block a user