* fix(measurements): Add measurement table functions - Support for labeling measurements and adding measurement description - Jump to measurement when clicked on measurement table * fix(layout): Fix the issues with layout when switched with different plugins * fix(measurements): Support for deleting measurements in measurement table * fix(measurements): Add context menu for measurements * fix(dependencies): Bump ohif-core to 0.4.2
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
export default function bounding(elementRef, currentPosition = {}) {
|
|
if (!elementRef.current) {
|
|
return
|
|
}
|
|
|
|
const currentElement = elementRef.current
|
|
const {
|
|
offsetParent,
|
|
offsetTop,
|
|
offsetHeight,
|
|
offsetLeft,
|
|
offsetWidth,
|
|
} = currentElement
|
|
let top = currentPosition.top || offsetTop
|
|
let left = currentPosition.left || offsetLeft
|
|
|
|
if (!offsetParent) {
|
|
return
|
|
}
|
|
|
|
let maxHeight = `${offsetParent.offsetHeight}px`
|
|
|
|
if (offsetHeight + top > offsetParent.offsetHeight) {
|
|
top = top - (offsetHeight + top - offsetParent.offsetHeight)
|
|
if (top < 0) {
|
|
top = 0
|
|
}
|
|
}
|
|
|
|
if (left + offsetWidth > offsetParent.offsetWidth) {
|
|
left = offsetParent.offsetWidth - offsetWidth
|
|
if (left < 0) {
|
|
left = 0
|
|
}
|
|
}
|
|
|
|
if (maxHeight && currentElement.style.maxHeight !== maxHeight) {
|
|
currentElement.style.maxHeight = maxHeight
|
|
}
|
|
if (currentElement.style.top !== `${top}px`) {
|
|
currentElement.style.top = `${top}px`
|
|
}
|
|
if (currentElement.style.left !== `${left}px`) {
|
|
currentElement.style.left = `${left}px`
|
|
}
|
|
}
|