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

[SwipeableDrawer] Decorrelate swipeAreaWidth and initial jumping amount #23042

Merged
merged 4 commits into from Oct 15, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js
Expand Up @@ -17,6 +17,9 @@ import SwipeArea from './SwipeArea';
// trigger a native scroll.
const UNCERTAINTY_THRESHOLD = 3; // px

// This is the part of the drawer displayed on touch start.
const DRAG_STARTED_SIGNAL = 20; // px

// We can only have one node at the time claiming ownership for handling the swipe.
// Otherwise, the UX would be confusing.
// That's why we use a singleton here.
Expand Down Expand Up @@ -351,9 +354,9 @@ const SwipeableDrawer = React.forwardRef(function SwipeableDrawer(inProps, ref)
// Compensate for the part of the drawer displayed on touch start.
if (!disableDiscovery && !open) {
if (horizontalSwipe) {
swipeInstance.current.startX -= swipeAreaWidth;
swipeInstance.current.startX -= DRAG_STARTED_SIGNAL;
} else {
swipeInstance.current.startY -= swipeAreaWidth;
swipeInstance.current.startY -= DRAG_STARTED_SIGNAL;
}
}
}
Expand Down Expand Up @@ -473,7 +476,7 @@ const SwipeableDrawer = React.forwardRef(function SwipeableDrawer(inProps, ref)
// The ref may be null when a parent component updates while swiping.
setPosition(
getMaxTranslate(horizontalSwipe, paperRef.current) +
(disableDiscovery ? 20 : -swipeAreaWidth),
(disableDiscovery ? 1 : -1) * DRAG_STARTED_SIGNAL,
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
{
changeTransition: false,
},
Expand Down