ant-design-vue/components/trigger/utils.js
2017-12-22 18:43:28 +08:00

28 lines
708 B
JavaScript

function isPointsEq (a1, a2) {
return a1[0] === a2[0] && a1[1] === a2[1]
}
export function getAlignFromPlacement (builtinPlacements, placementStr, align) {
const baseAlign = builtinPlacements[placementStr] || {}
return {
...baseAlign,
...align,
}
}
export function getPopupClassNameFromAlign (builtinPlacements, prefixCls, align) {
const points = align.points
for (const placement in builtinPlacements) {
if (builtinPlacements.hasOwnProperty(placement)) {
if (isPointsEq(builtinPlacements[placement].points, points)) {
return `${prefixCls}-placement-${placement}`
}
}
}
return ''
}
export function saveRef (name, component) {
this[name] = component
}