fix: window size readout now updates during drag
- ui.tsx: useWindowResize callback now builds a fresh {width,height} from
window.innerWidth/innerHeight instead of the hook's mutated ref object,
so Preact re-renders and the size label updates live
- toggleWindowSize: spread MIN/MAX constants to new objects (same ref bug)
This commit is contained in:
1 parent
26d391f90a
commit
4aa82fbefa
1 file changed
+6
-3
+6
-3
@@ -22,9 +22,12 @@ function Plugin () {
|
||||
// Нативный drag-ресайз окна Figma (тянуть за правый нижний угол).
|
||||
// Опции min/max обязательны: без них хук берёт базу из window.innerWidth на момент
|
||||
// маунта (окно ещё не приняло размер от showUI) → первый drag не работает.
|
||||
// ВАЖНО: хук мутирует и отдаёт ОДИН объект по ссылке, поэтому делаем копию
|
||||
// (иначе Preact не видит изменений и цифры размера не перерисовываются).
|
||||
useWindowResize(function (windowSize: { width: number; height: number }) {
|
||||
setCurrentWindowSize(windowSize)
|
||||
emit('RESIZE_WINDOW', windowSize)
|
||||
const size = { width: window.innerWidth, height: window.innerHeight }
|
||||
setCurrentWindowSize(size)
|
||||
emit('RESIZE_WINDOW', size)
|
||||
}, {
|
||||
minWidth: 320,
|
||||
minHeight: 200,
|
||||
@@ -36,7 +39,7 @@ function Plugin () {
|
||||
const isMaximized =
|
||||
currentWindowSize.width >= MAX_WINDOW_SIZE.width &&
|
||||
currentWindowSize.height >= MAX_WINDOW_SIZE.height
|
||||
const next = isMaximized ? MIN_WINDOW_SIZE : MAX_WINDOW_SIZE
|
||||
const next = isMaximized ? { ...MIN_WINDOW_SIZE } : { ...MAX_WINDOW_SIZE }
|
||||
setCurrentWindowSize(next)
|
||||
emit('RESIZE_WINDOW', next)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user