UNPKG

@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration

Version:

An optional Pragmatic drag and drop package that enables rapid migration from react-beautiful-dnd to Pragmatic drag and drop

29 lines (27 loc) 631 B
// eslint-disable-next-line import/no-extraneous-dependencies var directionMapping = { horizontal: { rect: { start: 'left', end: 'right' } }, vertical: { rect: { start: 'top', end: 'bottom' } } }; /** * Computes the distance between two `DOMRect` instances. * * This is the shortest distance from the end of one to the start of the next. */ export function getDistance(_ref) { var a = _ref.a, b = _ref.b, direction = _ref.direction; var rect = directionMapping[direction].rect; return Math.max(a[rect.start], b[rect.start]) - Math.min(a[rect.end], b[rect.end]); }