This commit is contained in:
32
node_modules/dnd-core/lib/reducers/dragOffset.js
generated
vendored
Normal file
32
node_modules/dnd-core/lib/reducers/dragOffset.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP, } from '../actions/dragDrop';
|
||||
import { areCoordsEqual } from '../utils/equality';
|
||||
const initialState = {
|
||||
initialSourceClientOffset: null,
|
||||
initialClientOffset: null,
|
||||
clientOffset: null,
|
||||
};
|
||||
export function reduce(state = initialState, action) {
|
||||
const { payload } = action;
|
||||
switch (action.type) {
|
||||
case INIT_COORDS:
|
||||
case BEGIN_DRAG:
|
||||
return {
|
||||
initialSourceClientOffset: payload.sourceClientOffset,
|
||||
initialClientOffset: payload.clientOffset,
|
||||
clientOffset: payload.clientOffset,
|
||||
};
|
||||
case HOVER:
|
||||
if (areCoordsEqual(state.clientOffset, payload.clientOffset)) {
|
||||
return state;
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
clientOffset: payload.clientOffset,
|
||||
};
|
||||
case END_DRAG:
|
||||
case DROP:
|
||||
return initialState;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user