Skip to content

Commit

Permalink
fixing flow
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed Jun 21, 2018
1 parent 9372d1e commit de8fee6
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 106 deletions.
2 changes: 1 addition & 1 deletion src/state/dimension-marshal/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default ({
const draggables: DraggableDimension[] = Object.keys(additions.draggables)
.map((id: DraggableId): DraggableDimension =>
// TODO
entries.draggables[id].getDimension(windowScroll, { x: 0, y: 0 })
entries.draggables[id].getDimension(windowScroll)
);

const droppables: DroppableDimension[] = Object.keys(additions.droppables)
Expand Down
16 changes: 8 additions & 8 deletions src/state/droppable-dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ export const scrollDroppable = (
return result;
};

// TODO
const growSubjectIfNeeded = ({
draggables: DraggableDimensionMap,
droppable: DroppableDimension,
addition: Position,
}): DroppableDimension => {

};
// TODO: make this work
// const growSubjectIfNeeded = ({
// draggables: DraggableDimensionMap,
// droppable: DroppableDimension,
// addition: Position,
// }): DroppableDimension => {

// };

13 changes: 3 additions & 10 deletions stories/src/dynamic/lazy-loading.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import QuoteList from '../primatives/quote-list';
import { DragDropContext } from '../../../src/';
import type { DropResult, DragUpdate, DragStart, DraggableLocation } from '../../../src/types';
import type { DropResult, DragUpdate, DraggableLocation } from '../../../src/types';
import type { Quote } from '../types';
import { quotes as initial, getQuotes } from '../data';
import reorder from '../reorder';
Expand All @@ -13,15 +13,13 @@ type State = {|
|}

export default class LazyLoading extends React.Component<*, State> {
// eslint-disable-next-line react/sort-comp
timerId: ?TimeoutID = null;
state: State = {
quotes: initial,
isLoading: false,
}

onDragStart = (start: DragStart) => {

}

onDragUpdate = (update: DragUpdate) => {
const destination: ?DraggableLocation = update.destination;
if (!destination) {
Expand All @@ -32,9 +30,6 @@ export default class LazyLoading extends React.Component<*, State> {
const startLoadingFrom: number = lastIndex - 2;

if (destination.index < startLoadingFrom) {
console.log('not far enough along');
console.log('destination', destination.index);
console.log('startLoading from', startLoadingFrom);
return;
}

Expand Down Expand Up @@ -72,7 +67,6 @@ export default class LazyLoading extends React.Component<*, State> {
}

startLazyLoading = () => {
console.log('starting lazy load');
if (this.state.isLoading) {
return;
}
Expand All @@ -96,7 +90,6 @@ export default class LazyLoading extends React.Component<*, State> {
render() {
return (
<DragDropContext
onDragStart={this.onDragStart}
onDragUpdate={this.onDragUpdate}
onDragEnd={this.onDragEnd}
>
Expand Down
9 changes: 1 addition & 8 deletions stories/src/primatives/quote-item.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
import { getBox } from 'css-box-model';
import React from 'react';
import styled from 'styled-components';
import { borderRadius, colors, grid } from '../constants';
Expand Down Expand Up @@ -100,20 +99,14 @@ const Attribution = styled.small`
// things we should be doing in the selector as we do not know if consumers
// will be using PureComponent
export default class QuoteItem extends React.PureComponent<Props> {
componentDidMount() {
console.log(`mounting center: ${this.props.quote.id}`, getBox(this.ref).borderBox.center);
}
render() {
const { quote, isDragging, provided } = this.props;

return (
<Container
href={quote.author.url}
isDragging={isDragging}
innerRef={(ref) => {
this.ref = ref;
provided.innerRef(ref);
}}
innerRef={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
>
Expand Down
2 changes: 2 additions & 0 deletions test/unit/state/get-displacement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const inViewport: DraggableDimension = getDraggableDimension({
descriptor: {
id: 'in-viewport',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -51,6 +52,7 @@ const notInViewport: DraggableDimension = getDraggableDimension({
descriptor: {
id: 'not-in-viewport',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 1,
},
// outside of viewport but within droppable
Expand Down
12 changes: 12 additions & 0 deletions test/unit/state/get-drag-impact.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'visible',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -419,6 +420,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'not-visible-1',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 1,
},
borderBox: {
Expand All @@ -433,6 +435,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'not-visible-2',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 2,
},
borderBox: {
Expand Down Expand Up @@ -510,6 +513,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'visible',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -523,6 +527,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'not-visible-1',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 1,
},
borderBox: {
Expand All @@ -537,6 +542,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'not-visible-2',
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 2,
},
borderBox: {
Expand Down Expand Up @@ -1020,6 +1026,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'inSource1',
droppableId: source.descriptor.id,
type: source.descriptor.type,
index: 0,
},
borderBox: {
Expand Down Expand Up @@ -1064,6 +1071,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'visible',
droppableId: destination.descriptor.id,
type: destination.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -1077,6 +1085,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'not-visible-1',
droppableId: destination.descriptor.id,
type: destination.descriptor.type,
index: 1,
},
borderBox: {
Expand Down Expand Up @@ -1158,6 +1167,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'inSource1',
droppableId: source.descriptor.id,
type: source.descriptor.type,
index: 0,
},
borderBox: {
Expand Down Expand Up @@ -1187,6 +1197,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'visible',
droppableId: destination.descriptor.id,
type: destination.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -1200,6 +1211,7 @@ describe('get drag impact', () => {
descriptor: {
id: 'not-visible-1',
droppableId: destination.descriptor.id,
type: destination.descriptor.type,
index: 1,
},
borderBox: {
Expand Down
8 changes: 6 additions & 2 deletions test/unit/state/get-droppable-over.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ describe('get droppable over', () => {
const draggable: DraggableDimension = getDraggableDimension({
descriptor: {
id: 'draggable',
droppableId: droppable.descriptor.type,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 0,
},
borderBox: {
Expand Down Expand Up @@ -142,7 +143,8 @@ describe('get droppable over', () => {
const draggable: DraggableDimension = getDraggableDimension({
descriptor: {
id: 'draggable',
droppableId: droppable.descriptor.type,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
index: 0,
},
borderBox: {
Expand Down Expand Up @@ -183,6 +185,7 @@ describe('get droppable over', () => {
descriptor: {
id: 'in-home-1',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -198,6 +201,7 @@ describe('get droppable over', () => {
descriptor: {
id: 'in-foreign-1',
droppableId: 'foreign',
type: home.descriptor.type,
index: 0,
},
borderBox: {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/state/move-to-next-index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ describe('move to next index', () => {
descriptor: {
id: 'inHome1',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 0,
},
borderBox: {
Expand All @@ -496,6 +497,7 @@ describe('move to next index', () => {
descriptor: {
id: 'inHome2',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 1,
},
borderBox: {
Expand All @@ -510,6 +512,7 @@ describe('move to next index', () => {
descriptor: {
id: 'inHome3',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 2,
},
borderBox: {
Expand All @@ -524,6 +527,7 @@ describe('move to next index', () => {
descriptor: {
id: 'inHome4',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 3,
},
borderBox: {
Expand All @@ -538,6 +542,7 @@ describe('move to next index', () => {
descriptor: {
id: 'inHome5',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 4,
},
borderBox: {
Expand All @@ -552,6 +557,7 @@ describe('move to next index', () => {
descriptor: {
id: 'inHome5',
droppableId: home.descriptor.id,
type: home.descriptor.type,
index: 5,
},
borderBox: {
Expand Down Expand Up @@ -1035,6 +1041,7 @@ describe('move to next index', () => {
id: 'inside',
index: 0,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
},
borderBox: customViewport.frame,
});
Expand All @@ -1043,6 +1050,7 @@ describe('move to next index', () => {
id: 'outside',
index: 1,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
},
borderBox: {
// is bottom left of the viewport
Expand Down Expand Up @@ -1122,6 +1130,7 @@ describe('move to next index', () => {
id: 'inside',
index: 0,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
},
borderBox: {
top: 0,
Expand All @@ -1135,6 +1144,7 @@ describe('move to next index', () => {
id: 'partial',
index: 1,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
},
borderBox: {
top: customViewport.frame.bottom + 1,
Expand Down Expand Up @@ -1227,6 +1237,7 @@ describe('move to next index', () => {
id: 'inside',
index: 0,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
},
borderBox: {
top: 0,
Expand All @@ -1241,6 +1252,7 @@ describe('move to next index', () => {
id: 'outside',
index: 1,
droppableId: droppable.descriptor.id,
type: droppable.descriptor.type,
},
borderBox: {
// in the droppable, but outside the frame
Expand Down
Loading

0 comments on commit de8fee6

Please sign in to comment.