fix: left/top resize — let Figma move window (no explicit reposition, kills jitter)
This commit is contained in:
1 parent
a86c3e3152
commit
20777fb0de
1 file changed
+5
-6
+5
-6
@@ -152,19 +152,18 @@ export default function () {
|
||||
on('RESIZE_WINDOW_DRAG', function (payload: { dx: number; dy: number; dir: string }) {
|
||||
if (resizeAnchor == null) return
|
||||
const { dx, dy, dir } = payload
|
||||
const zoom = figma.viewport.zoom || 1
|
||||
let w = resizeAnchor.w
|
||||
let h = resizeAnchor.h
|
||||
let nx = resizeAnchor.x
|
||||
let ny = resizeAnchor.y
|
||||
if (dir.indexOf('right') !== -1) w = resizeAnchor.w + dx
|
||||
if (dir.indexOf('left') !== -1) { w = resizeAnchor.w - dx; nx = resizeAnchor.x + dx / zoom }
|
||||
if (dir.indexOf('left') !== -1) w = resizeAnchor.w - dx
|
||||
if (dir.indexOf('bottom') !== -1) h = resizeAnchor.h + dy
|
||||
if (dir.indexOf('top') !== -1) { h = resizeAnchor.h - dy; ny = resizeAnchor.y + dy / zoom }
|
||||
if (dir.indexOf('top') !== -1) h = resizeAnchor.h - dy
|
||||
const size = clampWindowSize({ width: w, height: h })
|
||||
figma.ui.resize(size.width, size.height)
|
||||
lastSize = { width: size.width, height: size.height }
|
||||
figma.ui.reposition(nx, ny)
|
||||
// reposition НЕ вызываем: при resize Figma сама держит противоположный угол на месте
|
||||
// (для left/top окно сдвигается автоматически). Явный reposition конфликтует с этим
|
||||
// и даёт дрожание из-за округления getPosition() и 1/zoom.
|
||||
})
|
||||
|
||||
// Ресайз окна плагина (кастомные ручки по периметру -> RESIZE_WINDOW по pointerup)
|
||||
|
||||
Reference in new issue
Block a user