-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
@@ -0,0 +1,139 @@ | |||
# Screen reader guide |
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 guide is still a WIP
|} | ||
|} | ||
|
||
export const bulkPublishDimensions = ( |
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.
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', |
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.
we have a different Droppable scroll strategy for JUMP auto scrolling
// @flow | ||
import type { Area } from '../../types'; | ||
|
||
export default (frame: Area, subject: Area): boolean => |
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.
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', |
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.
renamed property to bring it in line with other crossAxis properties
...existing, | ||
current: { | ||
...existing.current, | ||
hasCompletedFirstBulkPublish: true, |
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.
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 |
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.
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)) { |
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.
we can exit a little early here
|
||
const origin: Position = { x: 0, y: 0 }; | ||
|
||
const isVisible = ({ |
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.
improved visibility checks
// may not have any destination (drag to nowhere) | ||
destination: ?DraggableLocation, | ||
|} | ||
|
||
export type DropReason = 'DROP' | 'CANCEL'; |
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.
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 |
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.
😁
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.
Yeah!! So good
} | ||
|
||
// We know this has a closestScrollable | ||
const closestScrollable: ClosestScrollable = (droppable.viewport.closestScrollable : any); |
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.
might be able to change line 285 to if (!droppable || !droppable.viewport.closestScrollable) {
to avoid having to cast through any here?
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.
changed
}; | ||
|
||
return jumpScroller; | ||
}; |
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 feel like the logic in this file is overly complicated. Can't it be simplified to something like this:
- We have the scroll request.
- 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.
- We scroll the window as much as we can to fulfill remainder A and subtract that again to get remainder B.
- 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?
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.
for sure
src/state/get-max-scroll.js
Outdated
|
||
return adjustedMaxScroll; | ||
|
||
// return maxScroll; |
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.
comment
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.
removed
src/view/announcer/announcer.js
Outdated
|
||
export default (): Announcer => { | ||
const id: string = `react-beautiful-dnd-announcement-${count++}`; | ||
// const id: string = 'react-beautiful-dnd-announcement'; |
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.
comment
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.
removed
This PR contains:
onDragUpdate
hook. Closes Extra information while dragging #298 Closes Screen reader support #311DraggableStateSnapshot
andDroppableStateSnapshot
. Closes Extra information while dragging #298data-*
hook toDroppables
for future global styling. Closes Wrong scroll position after drop in scroll container #290