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

Auto scrolling (and more!) #321

Merged
merged 166 commits into from
Feb 22, 2018
Merged

Auto scrolling (and more!) #321

merged 166 commits into from
Feb 22, 2018

Conversation

alexreardon
Copy link
Collaborator

@alexreardon alexreardon commented Feb 12, 2018

This PR contains:

@alexreardon alexreardon self-assigned this Feb 20, 2018
@@ -0,0 +1,139 @@
# Screen reader guide
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 guide is still a WIP

|}
|}

export const bulkPublishDimensions = (
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 one big action to bulk publish dimensions. This gets around a timing issue for onDragUpdate

@@ -469,7 +492,14 @@ export const lift = (id: DraggableId,
}

// will communicate with the marshal to start requesting dimensions
dispatch(requestDimensions(id));
const scrollOptions: ScrollOptions = {
shouldPublishImmediately: autoScrollMode === 'JUMP',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we have a different Droppable scroll strategy for JUMP auto scrolling

// @flow
import type { Area } from '../../types';

export default (frame: Area, subject: Area): boolean =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we do not auto scroll if the item is too big!

@@ -4,7 +4,7 @@ import type { HorizontalAxis, VerticalAxis } from '../types';
export const vertical: VerticalAxis = {
direction: 'vertical',
line: 'y',
crossLine: 'x',
crossAxisLine: 'x',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed property to bring it in line with other crossAxis properties

...existing,
current: {
...existing.current,
hasCompletedFirstBulkPublish: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

important new flag to prevent incorrect onDragUpdate announcements

}

const impact: ?DragImpact = (() => {
// we do not want to recalculate the initial impact until the first bulk publish is finished
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

boom. preventing incorrect onDragUpdate calls right here

console.error('cannot move with window scrolling if no current drag');
return clean();
}

if (isEqual(windowScroll, drag.current.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.

we can exit a little early here


const origin: Position = { x: 0, y: 0 };

const isVisible = ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

improved visibility checks

// may not have any destination (drag to nowhere)
destination: ?DraggableLocation,
|}

export type DropReason = 'DROP' | 'CANCEL';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we publish this reason to allow for improved screen reader messaging

}

// Only too big on one axis
// Exclude the axis that we cannot scroll on
Copy link
Contributor

Choose a reason for hiding this comment

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

😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah!! So good

}

// We know this has a closestScrollable
const closestScrollable: ClosestScrollable = (droppable.viewport.closestScrollable : any);
Copy link
Contributor

Choose a reason for hiding this comment

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

might be able to change line 285 to if (!droppable || !droppable.viewport.closestScrollable) { to avoid having to cast through any here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

};

return jumpScroller;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the logic in this file is overly complicated. Can't it be simplified to something like this:

  1. We have the scroll request.
  2. We scroll the droppable as much as we can to fulfill the request and subtract however far it could move from the request. This gives us a remainder A.
  3. We scroll the window as much as we can to fulfill remainder A and subtract that again to get remainder B.
  4. We move the draggable by remainder B. Now we're done.

If the remainder is zero at the end of any step we can bail early.

I think the specific checks to see if the droppable can scroll, or absorb the entire jump, or if the window can scroll, or absorb the entire jump etc. are redundant. If the window or the droppable can't scroll then we subtract zero from the request and move to the next step. If they can absorb all of the jump then the remainder is zero so nothing will be done in the subsequent steps.

I think that's basically what you're doing, but I don't know why case 1. and case 2. in the code are being treated as different paths?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for sure


return adjustedMaxScroll;

// return maxScroll;
Copy link
Contributor

Choose a reason for hiding this comment

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

comment

Copy link
Collaborator Author

@alexreardon alexreardon Feb 22, 2018

Choose a reason for hiding this comment

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

removed


export default (): Announcer => {
const id: string = `react-beautiful-dnd-announcement-${count++}`;
// const id: string = 'react-beautiful-dnd-announcement';
Copy link
Contributor

Choose a reason for hiding this comment

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

comment

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

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.

2 participants