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

droppable dimensions include the size of the draggable placeholder if… #132

Merged
merged 4 commits into from
Oct 12, 2017

Conversation

jaredcrowe
Copy link
Contributor

… they are a foreign list and were hovered on the previous tick

This addresses #122 by adding the placeholder size to a droppable's dimensions when it's being hovered.

@jaredcrowe
Copy link
Contributor Author

I've already noticed a bug with this - if a droppable has a min-height but not enough items to fill it out the placeholder size will still be added to its dimensions unnecessarily. I'll keep working on this.

@alexreardon
Copy link
Collaborator

Can you please explain the reasoning behind this change? If we merge #123 is this needed?

@alexreardon
Copy link
Collaborator

Can you please also find another reviewer for this one?

DroppableDimensionMap,
DroppableDimension,
} from '../types';

export default (
const noPadding: Position = { x: 0, y: 0 };
Copy link
Collaborator

Choose a reason for hiding this comment

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

rather than using the name padding which is already a thing, let's use another name. What about 'buffer'? or 'extra'?

noBuffer

isPointWithin(droppable)(target)
));
.find((droppable: DroppableDimension): boolean => {
const placeholderPadding = (() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the flow type to this variable as well as to the others in this file?

placeholderBuffer: Position

@@ -21,24 +26,37 @@ export const isPointWithin = (droppable: DroppableDimension) => {
// This gives us the droppable's true visible area
// Note: if the droppable doesn't have a scroll parent droppableBounds === container.page
const containerBounds = droppable.container.page.withoutMargin;
const clippedBounds: Spacing = {
const clippedBounds = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why loose the type?

export const isPointWithin = (droppable: DroppableDimension) => {
const noPadding: Position = { x: 0, y: 0 };

const getVisibleBounds = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

rather than adding an additional parameter here, perhaps we should create a function that add a Position or a Spacing to a DroppableDimension

@@ -107,17 +107,25 @@ const move = ({
windowScroll: currentWindowScroll,
};

const previousDroppableOver = state.drag && state.drag.impact.destination
Copy link
Collaborator

Choose a reason for hiding this comment

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

flow

}));

const drag: DragState = {
initial,
impact: newImpact,
current,
previous: {
droppableOver: previousDroppableOver,
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this just be the id and we keep the dimension within the state.dimension?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh sorry, I just saw it was the Id. Can this be changed to droppableOverId

@alexreardon
Copy link
Collaborator

These algorithms are also used by keyboard dragging. We need to check that they also hold up for that. Those algorithms already have logic for moving into the last place of a foreign droppable

@jaredcrowe
Copy link
Contributor Author

hey @alexreardon so #123 makes it a bit easier to drag into the last position of a full droppable because it includes the margin in the hit-box. This PR gives us the functionality we really want - including a placeholder's size in a droppable's dimension when appropriate.

Something like this is going to be necessary for implementing auto-scrolling, but I decided to pull it out into its own PR and try to get it in sooner because it improves the experience RE #122 as well.

If you have a chance (and I totally understand if you don't!) I'd be keen to get your thoughts on this approach. Currently I'm calculating the droppable's dimensions in real time during the drag (in the same place where we perform the runtime clipping), but I'm also considering capturing a 'withPlaceholder' fragment while capturing dimensions. If it's possible to do it once there I think it might be more performant. Might spike this approach on a separate branch too... 🤔

@alexreardon
Copy link
Collaborator

The upfront withPlaceholder sounds simplier to reason about just looking at it. Then everything to do with the dimension is in the one place

… they are a foreign list and were hovered on the previous tick
…sPointWithin from worrying about this. memoize runtime buffering logic where possible.
@jaredcrowe jaredcrowe force-pushed the droppable-dimension-includes-placeholder branch from 0b08ed0 to 40abf03 Compare October 9, 2017 05:04
@lukebatchelor
Copy link
Member

Sweet! Obviously I dont have a the requisite knowledge to comprehensively review this, but I've sat down with Jared and gone through the problem and the solution.

Happy to merge this and make any changes as necessary.

Copy link
Member

@lukebatchelor lukebatchelor left a comment

Choose a reason for hiding this comment

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

LGTM

@alexreardon
Copy link
Collaborator

I do not have time to review this properly so i'll lean on @lukebatchelor and @jaredcrowe. I will remove my review

@jaredcrowe jaredcrowe merged commit 506bf99 into master Oct 12, 2017
@alexreardon alexreardon deleted the droppable-dimension-includes-placeholder branch November 7, 2017 11:09
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.

3 participants