-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
get drag impact refactor #92
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0fead00
cleaning up get-drag-impact and simplifying how page properties are h…
alexreardon 6af5857
rewriting tests for get-drag-impact
alexreardon 2509780
more test cases
alexreardon 0ff22ce
continuing work on tests
alexreardon dd5c0bd
wip
alexreardon f714f62
wip
alexreardon 1392b33
tests for disabled droppable
alexreardon 20bed70
pulling home list and foriegn list functions apart
alexreardon 02ce65a
finalising refactor
alexreardon 31e0427
fixing unconnected draggable tests
alexreardon 2ab5768
Merge branch 'master' of github.com:atlassian/react-beautiful-dnd int…
alexreardon 23fcf78
removing temp file
alexreardon d87a782
laying out variables in a cleaner way
alexreardon 101a8c5
get-new-home-client-center now using new preset
alexreardon 9cc6f01
converting move-to-new-droppable tests to use new presets
alexreardon ba84b56
adding some variety to preset
alexreardon 5cfbc29
fixing flow issues
alexreardon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// @flow | ||
import type { | ||
DraggableId, | ||
DroppableId, | ||
DragMovement, | ||
DraggableDimension, | ||
DroppableDimension, | ||
DragImpact, | ||
Axis, | ||
Position, | ||
} from '../../types'; | ||
import { add, subtract, patch } from '../position'; | ||
|
||
type Args = {| | ||
pageCenter: Position, | ||
draggable: DraggableDimension, | ||
destination: DroppableDimension, | ||
insideDestination: DraggableDimension[], | ||
|} | ||
|
||
export default ({ | ||
pageCenter, | ||
draggable, | ||
destination, | ||
insideDestination, | ||
}: Args): DragImpact => { | ||
const axis: Axis = destination.axis; | ||
|
||
const destinationScrollDiff: Position = subtract( | ||
destination.scroll.current, destination.scroll.initial | ||
); | ||
|
||
const currentCenter: Position = add(pageCenter, destinationScrollDiff); | ||
|
||
const moved: DraggableId[] = insideDestination | ||
.filter((child: DraggableDimension): boolean => { | ||
// Items will be displaced forward if they sit ahead of the dragging item | ||
const threshold: number = child.page.withoutMargin[axis.end]; | ||
return threshold > currentCenter[axis.line]; | ||
}) | ||
.map((dimension: DraggableDimension): DroppableId => dimension.id); | ||
|
||
const newIndex: number = insideDestination.length - moved.length; | ||
|
||
const movement: DragMovement = { | ||
amount: patch(axis.line, draggable.page.withMargin[axis.size]), | ||
draggables: moved, | ||
isBeyondStartPosition: false, | ||
}; | ||
|
||
const impact: DragImpact = { | ||
movement, | ||
direction: axis.direction, | ||
destination: { | ||
droppableId: destination.id, | ||
index: newIndex, | ||
}, | ||
}; | ||
|
||
return impact; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed page from all these actions - easy to compute once with windowScroll in the reducer