diff --git a/src/state/get-drag-impact/in-home-list.js b/src/state/get-drag-impact/in-home-list.js index 67e1372414..8e13a11fd8 100644 --- a/src/state/get-drag-impact/in-home-list.js +++ b/src/state/get-drag-impact/in-home-list.js @@ -45,6 +45,10 @@ export default ({ const isBeyondStartPosition: boolean = currentCenter[axis.line] - originalCenter[axis.line] > 0; + console.log('original center', originalCenter); + console.log('current center', currentCenter); + console.log('isBeyondStartPosition', isBeyondStartPosition); + // Amount to move needs to include the margins const amount: Position = patch(axis.line, draggable.client.marginBox[axis.size]); @@ -86,18 +90,23 @@ export default ({ const ordered: Displacement[] = isBeyondStartPosition ? displaced.reverse() : displaced; const index: number = (() => { const startIndex = insideHome.indexOf(draggable); + console.log('start index', startIndex); const length: number = ordered.length; if (!length) { return startIndex; } if (isBeyondStartPosition) { + console.log('is beyond start position'); return startIndex + length; } // is moving backwards + console.log('moving backwards yolo'); return startIndex - length; })(); + console.log('calculated index', index); + const movement: DragMovement = { amount, displaced: ordered, diff --git a/src/state/reducer.js b/src/state/reducer.js index 38445d50bc..694649162d 100644 --- a/src/state/reducer.js +++ b/src/state/reducer.js @@ -230,15 +230,33 @@ export default (state: State = idle, action: Action): State => { // The starting index of a draggable can change during a drag const newCritical: Critical = critical || state.critical; + const homeImpact: DragImpact = { + movement: noMovement, + direction: dimensions.droppables[newCritical.droppable.id].axis.direction, + destination: { + index: newCritical.draggable.index, + droppableId: newCritical.droppable.id, + }, + }; + + // this will get the impact const impact: DragImpact = getDragImpact({ pageBorderBoxCenter: state.current.page.borderBoxCenter, draggable: dimensions.draggables[newCritical.draggable.id], draggables: dimensions.draggables, droppables: dimensions.droppables, - previousImpact: state.impact, + previousImpact: homeImpact, viewport, }); + if (critical) { + console.log('previous impact (home)', homeImpact); + console.log('critical', critical); + console.log('critical draggable', dimensions.draggables[newCritical.draggable.id]); + console.log('new impact', impact); + console.log('viewport', viewport); + } + // Moving into the DRAGGING phase if (state.phase === 'BULK_COLLECTING') { return { diff --git a/stories/src/dynamic/with-controls.jsx b/stories/src/dynamic/with-controls.jsx index 8a7bc53fdb..a278839af7 100644 --- a/stories/src/dynamic/with-controls.jsx +++ b/stories/src/dynamic/with-controls.jsx @@ -9,7 +9,7 @@ import { grid } from '../constants'; import type { Quote, QuoteMap, Author } from '../types'; import type { DropResult } from '../../../src/types'; -const intial: QuoteMap = generateQuoteMap(20); +const initial: QuoteMap = generateQuoteMap(4); const ControlSection = styled.div` margin: ${grid * 4}px; @@ -59,7 +59,7 @@ const createQuote = (() => { export default class WithControls extends React.Component<*, State> { state: State = { - quoteMap: intial, + quoteMap: initial, } componentDidMount() {