Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated placeholders #1096

Merged
merged 186 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
6d8cafe
initial
alexreardon Jan 29, 2019
060b39d
progress
alexreardon Jan 29, 2019
2bb787b
wip
alexreardon Jan 29, 2019
cf9f945
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Jan 30, 2019
d8221cb
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Jan 30, 2019
c5c6022
wip
alexreardon Jan 30, 2019
93e5387
animated draggable placeholder mount now working
alexreardon Jan 30, 2019
ceed2b6
animating droppable placeholder
alexreardon Jan 30, 2019
fdde9af
making context keys consistant
alexreardon Jan 30, 2019
0304272
using correct animations
alexreardon Jan 31, 2019
3e70c56
comments explaining delay
alexreardon Jan 31, 2019
79a606b
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Jan 31, 2019
9c05356
post window scroll update
alexreardon Jan 31, 2019
a263ad0
using transition end as mechanism for updating window max scroll
alexreardon Jan 31, 2019
1f84b41
no more draggable placeholder
alexreardon Jan 31, 2019
550fdf1
lots of love
alexreardon Jan 31, 2019
c2e13b1
drop impact
alexreardon Jan 31, 2019
6b354f5
adding comments
alexreardon Jan 31, 2019
9b9fd0e
wip
alexreardon Jan 31, 2019
a251d87
onlift
alexreardon Jan 31, 2019
f52804f
removing comment
alexreardon Jan 31, 2019
b4a56f5
wip
alexreardon Feb 1, 2019
a0c5fad
deciding on a strategy
alexreardon Feb 1, 2019
c32666c
adding explaination
alexreardon Feb 1, 2019
0ad5187
wip
alexreardon Feb 1, 2019
6944dd5
movement in home list is a go
alexreardon Feb 1, 2019
3903abc
wip
alexreardon Feb 1, 2019
63cb402
always keeping placeholder in home droppable to prevent list collapsing
alexreardon Feb 1, 2019
82dfa8b
animating the collapse of a home placeholder
alexreardon Feb 1, 2019
1cdad51
wip
alexreardon Feb 3, 2019
e10a9b5
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Feb 3, 2019
3b7709e
working on combine mode
alexreardon Feb 4, 2019
25f2785
collapsing grouping on drop
alexreardon Feb 4, 2019
cb27db8
beautiful merge drop animation
alexreardon Feb 4, 2019
7217cee
fixing bug in examples
alexreardon Feb 4, 2019
8083fad
wip
alexreardon Feb 4, 2019
a80b376
tiny cleanup
alexreardon Feb 4, 2019
3eb8c08
improved flow
alexreardon Feb 4, 2019
6301d93
wip
alexreardon Feb 4, 2019
5e4b571
adding draggingFromList
alexreardon Feb 4, 2019
11630ea
wip keyboard
alexreardon Feb 4, 2019
22238b2
grouping working within home list
alexreardon Feb 5, 2019
0f65a73
shame
alexreardon Feb 5, 2019
546edda
cross axis movement
alexreardon Feb 5, 2019
bf1f650
updating bundle size
alexreardon Feb 5, 2019
61a9aaa
removing logging
alexreardon Feb 5, 2019
f01147f
dynamic publishing wip
alexreardon Feb 5, 2019
dce0589
wip
alexreardon Feb 5, 2019
3f6fad9
first step
alexreardon Feb 5, 2019
2cb4b8c
goodbye old colors
alexreardon Feb 5, 2019
36aea37
adding global styles decorator
alexreardon Feb 5, 2019
777564c
nicer looking quote
alexreardon Feb 5, 2019
10b34c6
cleaner ids
alexreardon Feb 5, 2019
7b75b20
tests for animate-in-out
alexreardon Feb 5, 2019
e5c62b3
tests for animate-in-out
alexreardon Feb 6, 2019
54c2afd
child rendering tests
alexreardon Feb 6, 2019
35deb04
testing placeholder
alexreardon Feb 6, 2019
4812e38
cleanup and tests
alexreardon Feb 6, 2019
a6bb548
placeholder tests
alexreardon Feb 6, 2019
5ebf83f
removing unneeded file
alexreardon Feb 6, 2019
73ecc04
removing old files. fixing integration tests
alexreardon Feb 6, 2019
c18b365
draggable tests passing
alexreardon Feb 6, 2019
185d9fc
starting to test droppable
alexreardon Feb 7, 2019
528515c
fixing bug where a transitionend on a draggable coudl cause an instan…
alexreardon Feb 7, 2019
449453d
more tests
alexreardon Feb 7, 2019
6ceeab4
placeholder tests
alexreardon Feb 7, 2019
5b422a8
droppable tests
alexreardon Feb 7, 2019
7904639
updating tests yolo
alexreardon Feb 7, 2019
79db9cd
moving animation file
alexreardon Feb 8, 2019
d924a9a
adding slow animation
alexreardon Feb 10, 2019
828a11a
lets do this
alexreardon Feb 11, 2019
2799318
flowin
alexreardon Feb 11, 2019
29dc9b9
with flushing
alexreardon Feb 11, 2019
155125a
cleanup of connected droppable
alexreardon Feb 11, 2019
81cdf10
fixing flow issues
alexreardon Feb 11, 2019
9ba678c
adding tests
alexreardon Feb 11, 2019
5e1e2ac
cleaner context usage
alexreardon Feb 11, 2019
b704164
fixing draggable tests
alexreardon Feb 11, 2019
df017cf
now handled in a simplier way
alexreardon Feb 11, 2019
cec1624
comments
alexreardon Feb 11, 2019
dff9499
testing and refinements
alexreardon Feb 12, 2019
77d5453
renaming
alexreardon Feb 12, 2019
24276fd
fixing tests
alexreardon Feb 12, 2019
7c1a42a
wip
alexreardon Feb 12, 2019
7c53a17
tests for get-drag-impact
alexreardon Feb 12, 2019
18c6aff
more test
alexreardon Feb 12, 2019
5fec573
clarity to collision engine
alexreardon Feb 12, 2019
22512ec
fixing displacement-visibility tests
alexreardon Feb 12, 2019
5d5ceaf
more tests
alexreardon Feb 12, 2019
51ee332
wip
alexreardon Feb 12, 2019
a30b41d
wip
alexreardon Feb 12, 2019
b1f238e
welcome to pain
alexreardon Feb 13, 2019
cad5865
combine impact tests
alexreardon Feb 13, 2019
4a966f9
tests for combine impact
alexreardon Feb 13, 2019
ebf21ac
pulling out utils
alexreardon Feb 13, 2019
ec9ea88
making the world a better place
alexreardon Feb 13, 2019
c8f4772
moving tests around
alexreardon Feb 13, 2019
93aa4ab
little quote item tweak
alexreardon Feb 13, 2019
a4a070a
more tests
alexreardon Feb 13, 2019
6d50544
tests for combine impact
alexreardon Feb 13, 2019
be44d6c
more combine tests
alexreardon Feb 13, 2019
c466235
tests for combine impact
alexreardon Feb 13, 2019
2fcec25
fixing disabled droppables
alexreardon Feb 13, 2019
3d26c69
breaking up tests
alexreardon Feb 14, 2019
9fff710
adding more tests
alexreardon Feb 14, 2019
2316bc8
tests for reorder location
alexreardon Feb 14, 2019
28b2d0d
fixing droppable collection issue
alexreardon Feb 14, 2019
17d996b
when combining tests
alexreardon Feb 14, 2019
3bb8326
finishing combine impact tests
alexreardon Feb 14, 2019
db91f60
wip
alexreardon Feb 14, 2019
af6944f
initial
alexreardon Feb 15, 2019
23ddef6
creating valiation for test data
alexreardon Feb 15, 2019
3abf511
tests for droppable scroll
alexreardon Feb 15, 2019
2931569
removing old test file
alexreardon Feb 15, 2019
376cec3
fixing types
alexreardon Feb 15, 2019
ad4268f
writing tests for with placeholder
alexreardon Feb 17, 2019
5afec54
tests for moving to next position in home list
alexreardon Feb 17, 2019
4d01983
moving to next place in foreign list
alexreardon Feb 17, 2019
ad4715a
move to next combine - home list tests
alexreardon Feb 17, 2019
bd11e52
in foreign list tests
alexreardon Feb 17, 2019
91a760a
tests for starting displaced
alexreardon Feb 17, 2019
6c202cb
adding tests
alexreardon Feb 18, 2019
71408e3
removing old tests
alexreardon Feb 18, 2019
802430d
removing unused file
alexreardon Feb 18, 2019
7f278da
a bit cleaner speculative increase fn
alexreardon Feb 18, 2019
66df11f
breaking up and fixing get-displacement tests
alexreardon Feb 18, 2019
8c17d7d
blur example
alexreardon Feb 19, 2019
2e07ca4
moving to not visible place test
alexreardon Feb 19, 2019
3cbd7dd
tests for droppable visibility
alexreardon Feb 19, 2019
6413230
fixing existing get best draggable tests
alexreardon Feb 19, 2019
1e9d505
removing wrapping describe
alexreardon Feb 19, 2019
1cec335
tests for move to new droppable
alexreardon Feb 20, 2019
10aaf78
validate
alexreardon Feb 20, 2019
09af9ca
updating license date
alexreardon Feb 20, 2019
2e4de96
more tests
alexreardon Feb 20, 2019
4aea452
its happening
alexreardon Feb 20, 2019
d08ff4a
lift middleware
alexreardon Feb 20, 2019
3cefbf5
tests and cleanup
alexreardon Feb 20, 2019
c202f9a
moving test to correct position
alexreardon Feb 20, 2019
9887276
pulling tests out again
alexreardon Feb 20, 2019
b80de25
updating client-border-box tests
alexreardon Feb 20, 2019
c0024f1
tests for newhomeoffset
alexreardon Feb 20, 2019
fdd76d9
droping tests
alexreardon Feb 21, 2019
cdfaf01
test wip
alexreardon Feb 21, 2019
2b1b89d
conditional animation tests
alexreardon Feb 21, 2019
591ad7a
fixing middleware tests
alexreardon Feb 21, 2019
1aa1e71
pending drop middleware
alexreardon Feb 21, 2019
1f542d1
recompute tests
alexreardon Feb 21, 2019
eba3344
speculatively increase tests
alexreardon Feb 21, 2019
864bcce
fixing most responders tests
alexreardon Feb 21, 2019
f1295fe
test for onDragEnd
alexreardon Feb 21, 2019
05966d9
fail test if no assertion. drop middleware tests
alexreardon Feb 22, 2019
359e105
fixing connected draggable tests
alexreardon Feb 22, 2019
a4d5caf
combine with tests
alexreardon Feb 22, 2019
2e55097
all tests passing for connected-draggable
alexreardon Feb 22, 2019
c96e6fc
starting droppable tests
alexreardon Feb 22, 2019
39e9ce0
cleaning up droppable
alexreardon Feb 22, 2019
33a2a8c
wip
alexreardon Feb 22, 2019
84f42e3
still not accounting for flushing
alexreardon Feb 22, 2019
7381917
flush me crazy
alexreardon Feb 22, 2019
2e1a900
comments for connected droppable case
alexreardon Feb 22, 2019
da3fc5c
updating snapshot
alexreardon Feb 22, 2019
285125c
connected-draggable
alexreardon Feb 24, 2019
02c5dc7
connected-droppable
alexreardon Feb 24, 2019
07fd0cc
disabled-while-capturing test fix
alexreardon Feb 24, 2019
9d0e062
fixing flow
alexreardon Feb 24, 2019
66f42de
removing direction from impact
alexreardon Feb 24, 2019
d238799
not hiding placeholder for dynamic droppable collections
alexreardon Feb 25, 2019
45e0722
wip
alexreardon Feb 25, 2019
fe015d8
fingers crossed
alexreardon Feb 25, 2019
66a1755
yum
alexreardon Feb 25, 2019
7ec8de1
first test suite passing
alexreardon Feb 25, 2019
c67b104
test suite for addition scroll change modification
alexreardon Feb 25, 2019
bd1bc3f
update draggables tests
alexreardon Feb 25, 2019
b71c7e8
scroll change for droppables
alexreardon Feb 25, 2019
4cf676d
recomputing placeholders
alexreardon Feb 25, 2019
cb2f508
fixing droppable subject size test
alexreardon Feb 25, 2019
46be497
moving file
alexreardon Feb 25, 2019
212bb2b
dynamic update tests are passing
alexreardon Feb 25, 2019
7118cf6
middleware update-by-dynamic-change
alexreardon Feb 25, 2019
3d52b6a
dimension marshal tests
alexreardon Feb 25, 2019
78dff5d
fixing auto scroller tests
alexreardon Feb 25, 2019
e8a15de
returning patch dimension map
alexreardon Feb 25, 2019
1dca005
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon Feb 25, 2019
a327e90
updating snapshot
alexreardon Feb 25, 2019
c2d93e7
back to simple flow
alexreardon Feb 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"dist/react-beautiful-dnd.js": {
"bundled": 347275,
"minified": 134225,
"gzipped": 39798
"bundled": 355565,
"minified": 137929,
"gzipped": 40759
},
"dist/react-beautiful-dnd.min.js": {
"bundled": 295057,
"minified": 109593,
"gzipped": 31944
"bundled": 303204,
"minified": 113136,
"gzipped": 32811
},
"dist/react-beautiful-dnd.esm.js": {
"bundled": 228983,
"minified": 120746,
"gzipped": 30051,
"bundled": 236995,
"minified": 125149,
"gzipped": 31186,
"treeshaked": {
"rollup": {
"code": 81922,
"import_statements": 846
"code": 85449,
"import_statements": 832
},
"webpack": {
"code": 84599
"code": 88137
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { configure, addDecorator } from '@storybook/react';
import { withOptions } from '@storybook/addon-options';
import PopIframeDecorator from './decorator/pop-iframe';
import GlobalStylesDecorator from './decorator/global-styles';
// adding css reset - storybook includes a css loader
import '@atlaskit/css-reset';
import { version } from '../package.json';
Expand All @@ -10,10 +11,10 @@ addDecorator(
withOptions({
name: 'react-beautiful-dnd',
url: 'https://github.com/atlassian/react-beautiful-dnd',
showAddonPanel: false,
}),
);

addDecorator(GlobalStylesDecorator);
addDecorator(PopIframeDecorator);

// automatically import all files ending in *.stories.js
Expand Down
17 changes: 17 additions & 0 deletions .storybook/decorator/global-styles.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @flow
import React from 'react';
import styled from 'styled-components';
import { colors } from '@atlaskit/theme';
import { grid } from '../../stories/src/constants';

const GlobalStyles = styled.div`
background-color: ${colors.N0};
min-height: 100vh;
color: ${colors.N900};
`;

const GlobalStylesDecorator = (storyFn: Function) => (
<GlobalStyles>{storyFn()}</GlobalStyles>
);

export default GlobalStylesDecorator;
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017 Atlassian Pty Ltd
Copyright 2019 Atlassian Pty Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions docs/guides/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type DraggableStateSnapshot = {|
export type DraggableProps = {|
style: ?DraggableStyle,
'data-react-beautiful-dnd-draggable': string,
onTransitionEnd: ?(event: TransitionEvent) => void,
|};
type DraggableStyle = DraggingStyle | NotDraggingStyle;
type DraggingStyle = {|
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable flowtype/require-valid-file-annotation */

module.exports = {
setupFiles: ['./test/setup.js'],
setupFiles: ['./test/env-setup.js'],
setupTestFrameworkScriptFile: './test/test-setup.js',
// node_modules is default.
testPathIgnorePatterns: ['/node_modules/'],
watchPlugins: [
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"devDependencies": {
"@atlaskit/css-reset": "^3.0.5",
"@atlaskit/theme": "^7.0.4",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
Expand Down Expand Up @@ -128,7 +129,7 @@
"peerDependencies": {
"react": "^16.3.1"
},
"license": "Apache-2.0",
"license": "apache-2.0",
"jest-junit": {
"output": "test-reports/junit/js-test-results.xml"
}
Expand Down
29 changes: 26 additions & 3 deletions src/view/animation.js → src/animation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { Position } from 'css-box-model';
import { isEqual, origin } from '../state/position';
import { isEqual, origin } from './state/position';

export const curves = {
outOfTheWay: 'cubic-bezier(0.2, 0, 0, 1)',
Expand All @@ -19,8 +19,30 @@ export const combine = {
},
};

const outOfTheWayTime: number = 0.2;
const outOfTheWayTiming = `${outOfTheWayTime}s ${curves.outOfTheWay}`;
// export const timings = {
// outOfTheWay: 0.2,
// // greater than the out of the way time
// // so that when the drop ends everything will
// // have to be out of the way
// minDropTime: 0.33,
// maxDropTime: 0.55,
// };

// slow timings
// uncomment to use
export const timings = {
outOfTheWay: 2,
// greater than the out of the way time
// so that when the drop ends everything will
// have to be out of the way
minDropTime: 3,
maxDropTime: 4,
};

const outOfTheWayTiming: string = `${timings.outOfTheWay}s ${
curves.outOfTheWay
}`;
export const placeholderTransitionDelayTime: number = 0.1;

export const transitions = {
fluid: `opacity ${outOfTheWayTiming}`,
Expand All @@ -30,6 +52,7 @@ export const transitions = {
return `transform ${timing}, opacity ${timing}`;
},
outOfTheWay: `transform ${outOfTheWayTiming}`,
placeholder: `height ${outOfTheWayTiming}, width ${outOfTheWayTiming}, margin ${outOfTheWayTiming}`,
};

const moveTo = (offset: Position): ?string =>
Expand Down
7 changes: 6 additions & 1 deletion src/dev-warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ const isProduction: boolean = process.env.NODE_ENV === 'production';

// not replacing newlines (which \s does)
const spacesAndTabs: RegExp = /[ \t]{2,}/g;
const lineStartWithSpaces: RegExp = /^[ \t]*/gm;

// using .trim() to clear the any newlines before the first text and after last text
const clean = (value: string) => value.replace(spacesAndTabs, ' ').trim();
const clean = (value: string) =>
value
.replace(spacesAndTabs, ' ')
.replace(lineStartWithSpaces, '')
.trim();

const getDevMessage = (message: string) =>
clean(`
Expand Down
26 changes: 18 additions & 8 deletions src/state/action-creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import type {
Critical,
DraggableId,
DroppableId,
DropResult,
CompletedDrag,
MovementMode,
Viewport,
DimensionMap,
DropReason,
PendingDrop,
Published,
} from '../types';

Expand Down Expand Up @@ -240,24 +239,35 @@ export const clean = (): CleanAction => ({
payload: null,
});

export type AnimateDropArgs = {|
completed: CompletedDrag,
newHomeClientOffset: Position,
dropDuration: number,
|};

export type DropAnimateAction = {
type: 'DROP_ANIMATE',
payload: PendingDrop,
payload: AnimateDropArgs,
};

export const animateDrop = (pending: PendingDrop): DropAnimateAction => ({
export const animateDrop = (args: AnimateDropArgs): DropAnimateAction => ({
type: 'DROP_ANIMATE',
payload: pending,
payload: args,
});

export type DropCompleteArgs = {|
completed: CompletedDrag,
shouldFlush: boolean,
|};

export type DropCompleteAction = {
type: 'DROP_COMPLETE',
payload: DropResult,
payload: DropCompleteArgs,
};

export const completeDrop = (result: DropResult): DropCompleteAction => ({
export const completeDrop = (args: DropCompleteArgs): DropCompleteAction => ({
type: 'DROP_COMPLETE',
payload: result,
payload: args,
});

type DropArgs = {|
Expand Down
4 changes: 2 additions & 2 deletions src/state/can-start-drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export default (state: State, id: DraggableId): boolean => {
// the drop animation is complete. Otherwise they will be grabbing
// items not in their original position which can lead to bad visuals
// Not allowing dragging of the dropping draggable
if (state.pending.result.draggableId === id) {
if (state.completed.result.draggableId === id) {
return false;
}

// if dropping - allow lifting
// if cancelling - disallow lifting
return state.pending.result.reason === 'DROP';
return state.completed.result.reason === 'DROP';
};
2 changes: 0 additions & 2 deletions src/state/create-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import dropAnimationFinish from './middleware/drop-animation-finish';
import dimensionMarshalStopper from './middleware/dimension-marshal-stopper';
import autoScroll from './middleware/auto-scroll';
import pendingDrop from './middleware/pending-drop';
import updateViewportMaxScrollOnDestinationChange from './middleware/update-viewport-max-scroll-on-destination-change';
import type { DimensionMarshal } from './dimension-marshal/dimension-marshal-types';
import type { StyleMarshal } from '../view/style-marshal/style-marshal-types';
import type { AutoScroller } from './auto-scroller/auto-scroller-types';
Expand Down Expand Up @@ -79,7 +78,6 @@ export default ({
// When a drop animation finishes - fire a drop complete
dropAnimationFinish,
pendingDrop,
updateViewportMaxScrollOnDestinationChange,
autoScroll(getScroller),
// Fire responders for consumers (after update to store)
responders(getResponders, announce),
Expand Down
6 changes: 5 additions & 1 deletion src/state/dimension-marshal/dimension-marshal-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ export type GetDroppableDimensionFn = (
options: ScrollOptions,
) => DroppableDimension;

export type RecollectDroppableOptions = {|
withoutPlaceholder: boolean,
|};

export type DroppableCallbacks = {|
// a drag is starting
getDimensionAndWatchScroll: GetDroppableDimensionFn,
recollect: () => DroppableDimension,
recollect: (options: RecollectDroppableOptions) => DroppableDimension,
// scroll a droppable
scroll: (change: Position) => void,
// If the Droppable is listening for scroll events - it needs to stop!
Expand Down
7 changes: 7 additions & 0 deletions src/state/dimension-marshal/dimension-marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export default (callbacks: Callbacks) => {
callbacks: {
publish: callbacks.publishWhileDragging,
collectionStarting: callbacks.collectionStarting,
getCritical: (): Critical => {
invariant(
collection,
'Cannot get critical when there is no collection',
);
return collection.critical;
},
},
getEntries: (): Entries => entries,
});
Expand Down
17 changes: 15 additions & 2 deletions src/state/dimension-marshal/while-dragging-publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import type {
DraggableDimension,
DroppableDimension,
DraggableDescriptor,
Critical,
} from '../../types';
import type { Entries, DroppableEntry } from './dimension-marshal-types';
import type {
Entries,
DroppableEntry,
RecollectDroppableOptions,
} from './dimension-marshal-types';
import * as timings from '../../debug/timings';
import { origin } from '../position';
import { warning } from '../../dev-warning';
Expand Down Expand Up @@ -36,6 +41,7 @@ type Staging = {|
type Callbacks = {|
publish: (args: Published) => mixed,
collectionStarting: () => mixed,
getCritical: () => Critical,
|};

type Args = {|
Expand Down Expand Up @@ -89,6 +95,7 @@ export default ({ getEntries, callbacks }: Args): WhileDraggingPublisher => {
frameId = requestAnimationFrame(() => {
frameId = null;
callbacks.collectionStarting();
const critical: Critical = callbacks.getCritical();
timings.start(timingKey);

const entries: Entries = getEntries();
Expand All @@ -111,7 +118,13 @@ export default ({ getEntries, callbacks }: Args): WhileDraggingPublisher => {
(id: DroppableId) => {
const entry: ?DroppableEntry = entries.droppables[id];
invariant(entry, 'Cannot find dynamically added droppable in cache');
return entry.callbacks.recollect();
const isHome: boolean = entry.descriptor.id === critical.droppable.id;

// need to keep the placeholder when in home list
const options: RecollectDroppableOptions = {
withoutPlaceholder: !isHome,
};
return entry.callbacks.recollect(options);
},
);

Expand Down
16 changes: 4 additions & 12 deletions src/state/droppable/should-use-placeholder.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// @flow
import type { DraggableDescriptor, DragImpact, DroppableId } from '../../types';
import type { DraggableDescriptor, DragImpact } from '../../types';
import whatIsDraggedOver from './what-is-dragged-over';

export default (
descriptor: DraggableDescriptor,
impact: DragImpact,
): boolean => {
// use a placeholder when over a foreign list
const isOver: ?DroppableId = whatIsDraggedOver(impact);
if (!isOver) {
return false;
}
return isOver !== descriptor.droppableId;
};
// use placeholder if dragged over
export default (descriptor: DraggableDescriptor, impact: DragImpact): boolean =>
whatIsDraggedOver(impact) === descriptor.droppableId;
Loading