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

get drag impact refactor #92

Merged
merged 17 commits into from
Sep 18, 2017
Merged

get drag impact refactor #92

merged 17 commits into from
Sep 18, 2017

Conversation

alexreardon
Copy link
Collaborator

This PR is designed to simplify how we handle page values in the system - as well as the get-drag-impact function. I noticed that the get-drag-impact function was more complicated then it needed to be so I have simplified how it works.

This pull request does involve a functional change: currently the impact of a drag is based on the mouse selection point and not the center point which was not intended. Fixing that is as simple as changing the argument to getDragImpact from page.selection to page.center. However, I have gone all out and decided to clean the whole thing up a big before we move on.

I am providing all this detail in case i am unavailable to continue with it @jaredcrowe.

}

const insideDroppable: DraggableDimension[] = getDraggablesInsideDroppable(
droppable,
const source: DroppableDimension = droppables[draggable.droppableId];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hopefully this is much clearer now

@@ -79,55 +77,38 @@ const move = ({

const previous: CurrentDrag = state.drag.current;
const initial: InitialDrag = state.drag.initial;
const droppable: DroppableDimension = state.dimension.droppable[initial.source.droppableId];
const currentWindowScroll: Position = windowScroll || previous.windowScroll;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than everywhere calculating page - it does just done here based on the window scroll

};
return result;
})();

const scrollDiff: Position = subtract(droppable.scroll.initial, droppable.scroll.current);

const withinDroppable: WithinDroppable = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within droppable is gone. It was only used for get-drag-impact and the new function is much clearer

Copy link
Collaborator Author

@alexreardon alexreardon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that stuff

@@ -69,7 +69,6 @@ export type CompleteLiftAction = {|
id: DraggableId,
type: TypeId,
client: InitialDragLocation,
page: InitialDragLocation,
Copy link
Collaborator Author

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

@@ -1,182 +0,0 @@
// @flow
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now split into different files for clarity and simplification

|}

export default ({
pageCenter,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now calling this out explicitly

}: Args): DragImpact => {
const axis: Axis = home.axis;
const homeScrollDiff: Position = subtract(home.scroll.current, home.scroll.initial);
const originalCenter: Position = draggable.page.withoutMargin.center;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: check this position

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct - the ordering of the variables was a little funny so i have cleaned that up

Copy link
Collaborator Author

@alexreardon alexreardon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good now @jaredcrowe . I have updated all the tests that where using custom home inHome etc to use the new presets. Other files could be changed but i won't do it in this PR

@alexreardon alexreardon merged commit 4a75752 into master Sep 18, 2017
@alexreardon alexreardon deleted the handling-page-refactor branch September 18, 2017 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants