platform/plugins/board-resources/src/utils/PopupUtils.ts
Anna No 70579c2f47
Board: Extend popup positioning for Kanban card (#1483)
Signed-off-by: Anna No <anna.no@xored.com>
2022-04-21 22:05:09 +07:00

23 lines
738 B
TypeScript

import { PopupAlignment } from '@anticrm/ui'
import { HorizontalAlignment, VerticalAlignment } from '@anticrm/ui/src/types'
export function getPopupAlignment (e?: Event, position?: {v: VerticalAlignment, h: HorizontalAlignment}): PopupAlignment | undefined {
if (!e || !e.target) {
return undefined
}
const target = e.target as HTMLElement
return getElementPopupAlignment(target, position)
}
export function getElementPopupAlignment (el: HTMLElement, position?: {v: VerticalAlignment, h: HorizontalAlignment}): PopupAlignment | undefined {
if (el?.getBoundingClientRect) {
const result = el.getBoundingClientRect()
return {
getBoundingClientRect: () => result,
position
}
}
return undefined
}