feat: expand requests 2000x2000 so Figma clamps to its real window limit
This commit is contained in:
1 parent
0d61580acb
commit
960a2b0e03
1 file changed
+15
-7
+15
-7
@@ -188,12 +188,16 @@ function Plugin () {
|
||||
}, [])
|
||||
|
||||
function toggleWindowSize () {
|
||||
const max = windowInfo != null
|
||||
? windowInfo.maxViewport
|
||||
: { width: 800, height: 800 }
|
||||
// "Развернуть" шлёт заведомо большой запрос (2000×2000) — это "перфоратор" Figma:
|
||||
// API не отдаёт реальный лимит окна, поэтому просим больше, чем viewport, и Figma
|
||||
// сама клампнет до доступного (зависит от того, спрятан ли UI Figma). Реальный
|
||||
// размер потом измеряется через iframe (window.innerWidth/Height) и показывается
|
||||
// как lastSize / gaps. Свернуть — обратно к минимуму.
|
||||
const EXPAND_REQUEST = { width: 2000, height: 2000 }
|
||||
const isMaximized =
|
||||
currentWindowSize.width >= max.width && currentWindowSize.height >= max.height
|
||||
const next = isMaximized ? { ...MIN_WINDOW_SIZE } : { ...max }
|
||||
currentWindowSize.width >= EXPAND_REQUEST.width &&
|
||||
currentWindowSize.height >= EXPAND_REQUEST.height
|
||||
const next = isMaximized ? { ...MIN_WINDOW_SIZE } : { ...EXPAND_REQUEST }
|
||||
setCurrentWindowSize(next)
|
||||
emit('RESIZE_WINDOW', next)
|
||||
refreshInfo()
|
||||
@@ -208,9 +212,13 @@ function Plugin () {
|
||||
refreshInfo()
|
||||
}
|
||||
|
||||
const max = windowInfo != null ? windowInfo.maxViewport : { width: 800, height: 800 }
|
||||
const max = windowInfo != null ? windowInfo.maxViewport : null
|
||||
// "Развернуто" считаем, если окно достигло (или превысило) геометрию viewport
|
||||
// — при запросе 2000×2000 Figma клампнет, и lastSize будет ≥ maxViewport.
|
||||
const isMaximized =
|
||||
currentWindowSize.width >= max.width && currentWindowSize.height >= max.height
|
||||
max != null &&
|
||||
currentWindowSize.width >= max.width &&
|
||||
currentWindowSize.height >= max.height
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
|
||||
Reference in new issue
Block a user