Skip to content

floatingWindowGeometry

浮动窗口几何:钳制边界、拖拽缩放、最大化与级联默认尺寸。

函数签名

typescript
interface FloatingWindowBounds {
  x: number
  y: number
  width: number
  height: number
}

function clampFloatingWindowBounds(
  bounds: FloatingWindowBounds,
  constraints: FloatingWindowClampConstraints,
): FloatingWindowBounds

function createCascadedFloatingWindowBounds(
  options: CascadedFloatingWindowBoundsOptions,
): FloatingWindowBounds

function applyFloatingWindowResize(...): FloatingWindowBounds
function getMaximizedFloatingWindowBounds(...): FloatingWindowBounds
function createFloatingWindowResizeHandles(classPrefix: string): Array<{ edge, className }>

参数

函数主要参数说明
clampFloatingWindowBoundsbounds, constraints将 x/y/宽高限制在图层与 inset 内
createCascadedFloatingWindowBoundsviewportWidth/Height, insetTop/Bottom, widthRatio, heightRatio, offsetIndex居中尺寸 + 级联偏移
applyFloatingWindowResizestart, edge, dx, dy, constraints按拖拽边更新尺寸并钳制
getMaximizedFloatingWindowBoundslayerWidth, layerHeight, insetTop, insetBottom最大化铺满可用区域

返回值

类型说明
FloatingWindowBounds钳制或计算后的窗口矩形

工作原理

  1. 钳制:宽不超过图层宽、高不超过 layerHeight - insetTop - insetBottom;x/y 保证窗口完全落在可用区域内。
  2. 缩放:按 edge 组合(n/s/e/w 及四角)调整 origin 对角;低于 minWidth/minHeight 时回推 origin。
  3. 级联:按视口比例算默认宽高,再以 offsetIndex * cascadeStep 偏移 x/y,避免多窗完全重叠。
  4. 最大化:x=0,y=insetTop,宽=图层宽,高=扣除上下 inset 后的剩余高度。