diff --git a/src/main.ts b/src/main.ts
index ee9a293..1e4b83e 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -137,13 +137,13 @@ export default function () {
const size = clampWindowSize({ width, height })
figma.ui.resize(size.width, size.height)
lastSize = { width: size.width, height: size.height }
- if (dir.includes('left') || dir.includes('top')) {
+ if (dir.indexOf('left') !== -1 || dir.indexOf('top') !== -1) {
const zoom = figma.viewport.zoom || 1
const p = getPos()
let nx = p.x
let ny = p.y
- if (dir.includes('left')) nx = p.x - dx / zoom
- if (dir.includes('top')) ny = p.y - dy / zoom
+ if (dir.indexOf('left') !== -1) nx = p.x - dx / zoom
+ if (dir.indexOf('top') !== -1) ny = p.y - dy / zoom
figma.ui.reposition(nx, ny)
}
})
diff --git a/src/ui.tsx b/src/ui.tsx
index 1eb46ea..305583e 100644
--- a/src/ui.tsx
+++ b/src/ui.tsx
@@ -62,9 +62,8 @@ function Plugin () {
} | null>(null)
const [copied, setCopied] = useState(false)
- // Кастомный ресайз по ВСЕМУ периметру (8 ручек: 4 края + 4 угла). Нативный useWindowResize
- // давал только bottom-right; здесь handle'ы ловят pointerdown по всему периметру и шлют
- // dir + dx/dy в main, который для left/top двигает окно через reposition.
+ // Кастомный ресайз по ВСЕМУ периметру (8 невидимых ручек: 4 края + 4 угла).
+ // Левый/верхний края двигают окно (main двигает через reposition), правый/нижний — только resize.
// Live-обновление: RESIZE_WINDOW_DRAG во время drag'а, финальный RESIZE_WINDOW по pointerup.
function startResize (e: PointerEvent, dir: string) {
e.preventDefault()
@@ -84,14 +83,14 @@ function Plugin () {
const dy = e.clientY - resizeRef.current.startY
let w = resizeRef.current.startW
let h = resizeRef.current.startH
- if (dir.includes('right')) w = resizeRef.current.startW + dx
- if (dir.includes('left')) w = resizeRef.current.startW - dx
- if (dir.includes('bottom')) h = resizeRef.current.startH + dy
- if (dir.includes('top')) h = resizeRef.current.startH - dy
+ if (dir.indexOf('right') !== -1) w = resizeRef.current.startW + dx
+ if (dir.indexOf('left') !== -1) w = resizeRef.current.startW - dx
+ if (dir.indexOf('bottom') !== -1) h = resizeRef.current.startH + dy
+ if (dir.indexOf('top') !== -1) h = resizeRef.current.startH - dy
w = Math.max(320, w)
h = Math.max(200, h)
setCurrentWindowSize({ width: w, height: h })
- emit('RESIZE_WINDOW_DRAG', { width: w, height: h, dx, dy, dir })
+ emit('RESIZE_WINDOW_DRAG', { width: w, height: h, dx: dx, dy: dy, dir: dir })
}
function onPointerUpResize () {
@@ -390,32 +389,16 @@ function Plugin () {