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
Improving box model #471
Conversation
src/state/action-creators.js
Outdated
movement: impact.movement, | ||
draggable, | ||
draggables: state.dimension.draggable, | ||
destination, | ||
}); | ||
|
||
const clientOffset: Position = subtract(newCenter, draggable.client.marginBox.center); | ||
// TODO: WHAT!@? |
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.
remove TODO
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.
done
@@ -344,14 +344,15 @@ export const drop = () => | |||
reason: 'DROP', | |||
}; | |||
|
|||
const newCenter: Position = getNewHomeClientCenter({ | |||
const newBorderBoxCenter: Position = getNewHomeClientBorderBoxCenter({ |
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.
more explicit naming all over the place
@@ -1,245 +0,0 @@ | |||
// @flow |
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.
gone. Now done mostly by css-box-model
as well as droppable-dimension.js
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.
😮
@@ -54,25 +56,25 @@ export default ({ | |||
return false; | |||
} | |||
|
|||
const area: Area = child.page.borderBox; | |||
const borderBox: Rect = child.page.borderBox; |
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.
super clear now
} | ||
|
||
// All the draggables in the destination (even the ones that haven't moved) | ||
const draggablesInDestination: DraggableDimension[] = getDraggablesInsideDroppable( | ||
destination, draggables | ||
); | ||
|
||
// const data = (() => { |
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.
TODO: remove
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.
done
@@ -15,7 +15,7 @@ import type { | |||
|
|||
type Args = {| | |||
amount: Position, | |||
pageCenter: Position, | |||
pageBorderBoxCenter: Position, |
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.
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 => ({ |
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.
No longer needed. This is done in css-box-model
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 |
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.
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 |
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.
😮
@@ -11,7 +11,7 @@ import type { | |||
export type Args = {| | |||
isMovingForward: boolean, | |||
draggableId: DraggableId, | |||
previousPageCenter: Position, | |||
previousPageBorderBoxCenter: Position, |
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.
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; |
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.
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 🙂
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.
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'; |
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.
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; |
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.
destructure these?
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.
I wanted to give the types explicitly - especially for the client: BoxModel
so that it is clear
No description provided.