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 }>参数
| 函数 | 主要参数 | 说明 |
|---|---|---|
clampFloatingWindowBounds | bounds, constraints | 将 x/y/宽高限制在图层与 inset 内 |
createCascadedFloatingWindowBounds | viewportWidth/Height, insetTop/Bottom, widthRatio, heightRatio, offsetIndex | 居中尺寸 + 级联偏移 |
applyFloatingWindowResize | start, edge, dx, dy, constraints | 按拖拽边更新尺寸并钳制 |
getMaximizedFloatingWindowBounds | layerWidth, layerHeight, insetTop, insetBottom | 最大化铺满可用区域 |
返回值
| 类型 | 说明 |
|---|---|
FloatingWindowBounds | 钳制或计算后的窗口矩形 |
工作原理
- 钳制:宽不超过图层宽、高不超过
layerHeight - insetTop - insetBottom;x/y 保证窗口完全落在可用区域内。 - 缩放:按
edge组合(n/s/e/w 及四角)调整 origin 对角;低于minWidth/minHeight时回推 origin。 - 级联:按视口比例算默认宽高,再以
offsetIndex * cascadeStep偏移 x/y,避免多窗完全重叠。 - 最大化:x=0,y=insetTop,宽=图层宽,高=扣除上下 inset 后的剩余高度。