Skip to content

Commit

Permalink
yeah
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed Jun 12, 2018
1 parent bdf35bc commit abb3abc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/state/bulk-replace/with-critical-replacement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import invariant from 'tiny-invariant';
import type { Position } from 'css-box-model';
import { add, subtract } from '../position';
import { add, subtract, isEqual } from '../position';
import getDragImpact from '../get-drag-impact';
import getHomeImpact from '../get-home-impact';
import type {
Expand Down Expand Up @@ -33,11 +34,23 @@ export default ({
critical,
dimensions,
}: Args): Result => {
const oldClientBorderBoxCenter: Position = state.initial.client.borderBoxCenter;
const draggable: DraggableDimension = dimensions.draggables[critical.draggable.id];

invariant(isEqual(draggable.client.borderBox.center, state.current.client.borderBoxCenter),
`Collected client borderBox center: ${JSON.stringify(draggable.client.borderBox.center)}
does not match the previously current client center: ${JSON.stringify(state.current.client.borderBoxCenter)}`
);

invariant(isEqual(draggable.page.borderBox.center, state.current.page.borderBoxCenter),
`Collected page borderBox center: ${JSON.stringify(draggable.page.borderBox.center)}
does not match the previously current page center: ${JSON.stringify(state.current.page.borderBoxCenter)}`
);

const oldClientBorderBoxCenter: Position = state.initial.client.borderBoxCenter;
const newClientBorderBoxCenter: Position = draggable.client.borderBox.center;
// How much the dragging item is shifting
const centerDiff: Position = subtract(newClientBorderBoxCenter, oldClientBorderBoxCenter);
console.warn('CENTER DIFF', centerDiff);

const oldInitialClientSelection: Position = state.initial.client.selection;
const newInitialClientSelection: Position = add(oldInitialClientSelection, centerDiff);
Expand Down Expand Up @@ -80,10 +93,12 @@ export default ({

console.group('critical replacement');
console.log('NEW START INDEX', critical.draggable.index);
console.log('PRE-UPDATE: initial page center', state.initial.page.borderBoxCenter)
console.log('PRE-UPDATE: current page center', state.current.page.borderBoxCenter)
console.log('PRE-UPDATE: initial page center', state.initial.page.borderBoxCenter);
console.log('PRE-UPDATE: current page center', state.current.page.borderBoxCenter);
console.warn('POST-UPDATE: initial page center', initial.page.borderBoxCenter);
console.warn('POST-UPDATE: current page center', current.page.borderBoxCenter);
// console.log('PRE (generated-1): page center', state.dimensions.draggables['generated-1'].page.borderBox.center)
// console.log('POST(generated-1): page center', dimensions.draggables['generated-1'].page.borderBox.center)
console.log('home impact', getHomeImpact(critical, dimensions));

const impact: DragImpact = getDragImpact({
Expand All @@ -100,7 +115,6 @@ export default ({
console.log('displaced', impact.movement.displaced.map(entry => entry.draggableId));
console.groupEnd();


// stripping out any animations
const forcedNoAnimations: DragImpact = {
...impact,
Expand Down
6 changes: 6 additions & 0 deletions src/state/get-drag-impact/in-home-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ export default ({
previousImpact,
viewport,
}: Args): DragImpact => {
console.group('in home list');
const axis: Axis = home.axis;
// The starting center position
const originalCenter: Position = draggable.page.borderBox.center;
console.log('original page center', originalCenter);

// Where the element actually is now.
// Need to take into account the change of scroll in the droppable
const currentCenter: Position = withDroppableScroll(home, pageBorderBoxCenter);

console.log('current page center', currentCenter);

// not considering margin so that items move based on visible edges
const isBeyondStartPosition: boolean =
currentCenter[axis.line] - originalCenter[axis.line] > 0;
Expand All @@ -50,6 +54,8 @@ export default ({
// Amount to move needs to include the margins
const amount: Position = patch(axis.line, draggable.client.marginBox[axis.size]);

console.groupEnd();

const displaced: Displacement[] = insideHome
.filter((child: DraggableDimension): boolean => {
// do not want to move the item that is dragging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export default class DraggableDimensionPublisher extends Component<Props> {
// from when the drag started
const undoWindowScroll: Position = negate(windowScrollDiff);

console.log('offseting dragging item by', add(undoTransform, undoWindowScroll));

return add(undoTransform, undoWindowScroll);
})();

Expand Down

0 comments on commit abb3abc

Please sign in to comment.