UNPKG

react-beautiful-dnd-next

Version:

Beautiful and accessible drag and drop for lists with React

30 lines (25 loc) 747 B
// @flow import type { Position } from 'css-box-model'; import type { Viewport, DraggableDimension } from '../../../types'; import { add, subtract } from '../../position'; import withViewportDisplacement from '../../with-scroll-change/with-viewport-displacement'; type Args = {| pageBorderBoxCenter: Position, draggable: DraggableDimension, viewport: Viewport, |}; export default ({ pageBorderBoxCenter, draggable, viewport, }: Args): Position => { const withoutPageScrollChange: Position = withViewportDisplacement( viewport, pageBorderBoxCenter, ); const offset: Position = subtract( withoutPageScrollChange, draggable.page.borderBox.center, ); return add(draggable.client.borderBox.center, offset); };