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

Improving box model #471

Merged
merged 35 commits into from Apr 27, 2018
Merged

Improving box model #471

merged 35 commits into from Apr 27, 2018

Conversation

alexreardon
Copy link
Collaborator

No description provided.

movement: impact.movement,
draggable,
draggables: state.dimension.draggable,
destination,
});

const clientOffset: Position = subtract(newCenter, draggable.client.marginBox.center);
// TODO: WHAT!@?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

remove TODO

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -344,14 +344,15 @@ export const drop = () =>
reason: 'DROP',
};

const newCenter: Position = getNewHomeClientCenter({
const newBorderBoxCenter: Position = getNewHomeClientBorderBoxCenter({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

more explicit naming all over the place

@@ -1,245 +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.

gone. Now done mostly by css-box-model as well as droppable-dimension.js

Copy link
Contributor

Choose a reason for hiding this comment

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

😮

@@ -54,25 +56,25 @@ export default ({
return false;
}

const area: Area = child.page.borderBox;
const borderBox: Rect = child.page.borderBox;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

super clear now

}

// All the draggables in the destination (even the ones that haven't moved)
const draggablesInDestination: DraggableDimension[] = getDraggablesInsideDroppable(
destination, draggables
);

// const data = (() => {
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: remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -15,7 +15,7 @@ import type {

type Args = {|
amount: Position,
pageCenter: Position,
pageBorderBoxCenter: 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.

much clearer naming

@@ -20,34 +17,13 @@ export const expandByPosition = (spacing: Spacing, position: Position): Spacing
bottom: spacing.bottom + position.y,
});

export const expandBySpacing = (spacing1: Spacing, spacing2: Spacing): Spacing => ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No longer needed. This is done in css-box-model

@alexreardon
Copy link
Collaborator Author

This is in preparation for #461. I have not fixed that issue in this PR, but we really needed to improve our internal box model usage (again) to clearly resolve the issue

Copy link
Contributor

@jaredcrowe jaredcrowe 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 great dude, so much easier to form a mental picture of what's going on at any point in the code. I left a few nitpick comments around the place 🙂

@@ -1,245 +0,0 @@
// @flow
Copy link
Contributor

Choose a reason for hiding this comment

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

😮

@@ -11,7 +11,7 @@ import type {
export type Args = {|
isMovingForward: boolean,
draggableId: DraggableId,
previousPageCenter: Position,
previousPageBorderBoxCenter: Position,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we be importing Position from css-box-model here (and anywhere else Position is imported)?

src/types.js Outdated
|}
// For simplicity exporting these from here as they are used
// very frequently within the code
export type Position = PositionType;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's be consistent about whether we remove these types and import directly from css-box-model wherever needed, or whether we keep these and make sure everything imports from here. I've noticed both approaches throughout the code 🙂

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 was helpful in my conversion - but i agree that it should be removed

import PropTypes from 'prop-types';
import memoizeOne from 'memoize-one';
import invariant from 'tiny-invariant';
import { calculateBox, withScroll } from 'css-box-model';
import type { BoxModel } from 'css-box-model';
Copy link
Contributor

Choose a reason for hiding this comment

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

can we consolidate these lines?

const { borderBox, margin, display, tagName } = placeholder;
const client: BoxModel = placeholder.client;
const display: string = placeholder.display;
const tagName: string = placeholder.tagName;
Copy link
Contributor

Choose a reason for hiding this comment

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

destructure these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to give the types explicitly - especially for the client: BoxModel so that it is clear

@alexreardon alexreardon merged commit 7179eaf into master Apr 27, 2018
@alexreardon alexreardon deleted the outsourcing-box-model branch April 27, 2018 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants