fix: corners only move window, keep size (don't stretch)
This commit is contained in:
1 parent
e57e4c18ea
commit
61577b01cd
1 file changed
+4
-8
+4
-8
@@ -28,7 +28,7 @@ export default function () {
|
||||
// Вычислить целевое состояние окна для позиции докинга:
|
||||
// - Лево/Право: ширина 320px, высота = макс (весь viewport по вертикали минус шапка)
|
||||
// - Верх/Низ: высота 320px, ширина = макс (весь viewport по горизонтали)
|
||||
// - Углы: ширина и высота = макс (растянуть обе оси на весь viewport)
|
||||
// - Углы: НЕ меняют размер, только прижимают к соответствующему углу viewport
|
||||
// - Центр: размер = 50% viewport (по ширине и высоте), центрируется
|
||||
// Возвращает размер (экранные px) и позицию (canvas-space, прижатую к нужному краю).
|
||||
const DOCK_EDGE_SIZE = 320
|
||||
@@ -37,19 +37,13 @@ export default function () {
|
||||
const zoom = figma.viewport.zoom || 1
|
||||
const maxW = Math.round(b.width * zoom)
|
||||
const maxH = Math.round(b.height * zoom) - PLUGIN_HEADER_PX
|
||||
const isCorner =
|
||||
position === 'top-left' || position === 'top-right' ||
|
||||
position === 'bottom-left' || position === 'bottom-right'
|
||||
const isLeftRight = position === 'center-left' || position === 'center-right'
|
||||
const isTopBottom = position === 'top-center' || position === 'bottom-center'
|
||||
const isCenter = position === 'center'
|
||||
|
||||
let targetW = currentWidth
|
||||
let targetH = currentHeight
|
||||
if (isCorner) {
|
||||
targetW = maxW
|
||||
targetH = maxH
|
||||
} else if (isLeftRight) {
|
||||
if (isLeftRight) {
|
||||
targetW = DOCK_EDGE_SIZE
|
||||
targetH = maxH
|
||||
} else if (isTopBottom) {
|
||||
@@ -59,6 +53,8 @@ export default function () {
|
||||
targetW = Math.round(maxW / 2)
|
||||
targetH = Math.round(maxH / 2)
|
||||
}
|
||||
// Углы (top-left/right, bottom-left/right): размер НЕ меняем (targetW/targetH = current),
|
||||
// только позиция прижимается к соответствующему углу viewport.
|
||||
// canvas-units от целевого размера
|
||||
const wCanvas = targetW / zoom
|
||||
const hCanvas = (PLUGIN_HEADER_PX + targetH) / zoom
|
||||
|
||||
Reference in new issue
Block a user