Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | export function DragPosCalc({ x, y, element, dragWrapper, boundaryLimit }) { let { top, left, right, bottom } = boundaryLimit; const offsetWidth = element ? element.offsetWidth : 0; const offsetHeight = element ? element.offsetHeight : 0; const topOffset = top ? offsetHeight - top : 0; const leftOffset = left ? offsetWidth - left : 0; const rightOffset = right ? offsetWidth - right : 0; const bottomOffset = bottom ? offsetHeight - bottom : 0; x = Math.max(-leftOffset, Math.min(x, dragWrapper.offsetWidth - element.offsetWidth + rightOffset)); y = Math.max(-topOffset, Math.min(y, dragWrapper.offsetHeight - element.offsetHeight + bottomOffset)); return { x, y }; } |