mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-15 04:49:00 +00:00
23 lines
738 B
TypeScript
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
|
|
}
|