You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
688 B
31 lines
688 B
|
3 years ago
|
import { withScroll, offset as offsetBox } from 'css-box-model';
|
||
|
|
import type { Position, BoxModel } from 'css-box-model';
|
||
|
|
import type { DraggableDimension } from '../../types';
|
||
|
|
|
||
|
|
interface Args {
|
||
|
|
draggable: DraggableDimension;
|
||
|
|
offset: Position;
|
||
|
|
initialWindowScroll: Position;
|
||
|
|
}
|
||
|
|
|
||
|
|
export default ({
|
||
|
|
draggable,
|
||
|
|
offset,
|
||
|
|
initialWindowScroll,
|
||
|
|
}: Args): DraggableDimension => {
|
||
|
|
const client: BoxModel = offsetBox(draggable.client, offset);
|
||
|
|
const page: BoxModel = withScroll(client, initialWindowScroll);
|
||
|
|
|
||
|
|
const moved: DraggableDimension = {
|
||
|
|
...draggable,
|
||
|
|
placeholder: {
|
||
|
|
...draggable.placeholder,
|
||
|
|
client,
|
||
|
|
},
|
||
|
|
client,
|
||
|
|
page,
|
||
|
|
};
|
||
|
|
|
||
|
|
return moved;
|
||
|
|
};
|