Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed Jun 17, 2018
1 parent c542979 commit 41ecab2
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 140 deletions.
7 changes: 6 additions & 1 deletion src/state/dimension-marshal/dimension-marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default (callbacks: Callbacks) => {
);

// Not relevant to the drag
if (collection.critical.draggable.type !== descriptor.type) {
if (descriptor.type !== collection.critical.draggable.type) {
return;
}

Expand All @@ -143,6 +143,11 @@ export default (callbacks: Callbacks) => {
return;
}

// Not relevant to this drag
if (descriptor.type !== collection.critical.droppable.type) {
return;
}

publisher.addDroppable(id);
};

Expand Down
55 changes: 28 additions & 27 deletions src/state/dimension-marshal/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Callbacks = {|

type Args = {|
getProvided: () => Provided,
getEntries: () => Entries,
callbacks: Callbacks
|}

Expand All @@ -53,41 +54,41 @@ const getEmptyMap = (): Map => ({

const timingKey: string = 'Publish collection from DOM';

const advancedUsageWarning = (() => {
// noop for production
if (process.env.NODE_ENV === 'production') {
return () => { };
}
export default ({
getProvided,
callbacks,
}: Args): Publisher => {
const advancedUsageWarning = (() => {
// noop for production
if (process.env.NODE_ENV === 'production') {
return () => { };
}

let hasAnnounced: boolean = false;
let hasAnnounced: boolean = false;

return () => {
if (hasAnnounced) {
return;
}
return () => {
if (hasAnnounced) {
return;
}

hasAnnounced = true;
hasAnnounced = true;

console.warn(`
Advanced usage warning: you are adding or removing a dimension during a drag
This an advanced feature used to support dynamic interactions such as lazy loading lists.
console.warn(`
Advanced usage warning: you are adding or removing a dimension during a drag
This an advanced feature used to support dynamic interactions such as lazy loading lists.
Keep in mind the following restrictions:
Keep in mind the following restrictions:
- Draggable's can only be added to Droppable's that are scroll containers
- Adding a Droppable cannot impact the placement of other Droppables
(it cannot push a Droppable on the page)
- Draggable's can only be added to Droppable's that are scroll containers
- Adding a Droppable cannot impact the placement of other Droppables
(it cannot push a Droppable on the page)
(This warning will be stripped in production builds)
`.trim()
);
};
})();
(This warning will be stripped in production builds)
`.trim()
);
};
})();

export default ({
getProvided,
callbacks,
}: Args): Publisher => {
let additions: Map = getEmptyMap();
let removals: Map = getEmptyMap();
let frameId: ?AnimationFrameID = null;
Expand Down
81 changes: 0 additions & 81 deletions src/state/dimension-marshal/simple-collector.js

This file was deleted.

31 changes: 31 additions & 0 deletions src/state/dimension-structures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @flow
import type {
DroppableId,
DraggableId,
DroppableDimension,
DroppableDimensionMap,
DraggableDimension,
DraggableDimensionMap,
} from '../types';

export const toDroppableMap =
(droppables: DroppableDimension[]): DroppableDimensionMap =>
droppables.reduce((previous, current) => {
previous[current.descriptor.id] = current;
return previous;
}, {});

export const toDraggableMap =
(draggables: DraggableDimension[]): DraggableDimensionMap =>
draggables.reduce((previous, current) => {
previous[current.descriptor.id] = current;
return previous;
}, {});

export const toDroppableList =
(droppables: DroppableDimensionMap): DroppableDimension[] =>
Object.keys(droppables).map((id: DroppableId): DroppableDimension => droppables[id]);

export const toDraggableList =
(draggables: DraggableDimensionMap): DraggableDimension[] =>
Object.keys(draggables).map((id: DraggableId): DraggableDimension => draggables[id]);
2 changes: 1 addition & 1 deletion src/state/publish/get-dimension-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
DraggableDimensionMap,
DroppableDimensionMap,
} from '../../types';
import { toDroppableMap, toDraggableMap } from '../to-map';
import { toDroppableMap, toDraggableMap } from '../dimension-structures';
import { patch } from '../position';
import * as timings from '../../debug/timings';

Expand Down
18 changes: 0 additions & 18 deletions src/state/to-map.js

This file was deleted.

Loading

0 comments on commit 41ecab2

Please sign in to comment.