Skip to content

getMainAxisFlip

获取主轴翻转后的 Placement。

函数签名

typescript
function getMainAxisFlip(placement: Placement): Placement

type Placement = 
  | 'top' | 'top-start' | 'top-end'
  | 'bottom' | 'bottom-start' | 'bottom-end'
  | 'left' | 'left-start' | 'left-end'
  | 'right' | 'right-start' | 'right-end'

参数

参数名类型必填说明
placementPlacement原始定位方式

返回值

类型说明
Placement主轴翻转后的定位方式

工作原理

根据基础方向和对齐方式,计算主轴翻转后的 Placement:

  • top-starttop-end
  • bottom-startbottom-end
  • left-startleft-end
  • right-startright-end

用于弹出层位置调整,当原始位置超出视口时自动翻转对齐方式。