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

Add 'swipe away' functionality to the left / right nav #614

Merged
merged 3 commits into from
May 12, 2015

Conversation

pomerantsev
Copy link
Contributor

Resolves #411.

If a user opens the nav on a touch device, they can use the swipe
gesture they're used to to close the nav.

Technical details: I initially tried setting nav's translateX and
overlay's opacity using setState, but turns out that on mobile devices
re-rendering the component on every touchmove event is costly and
leads to laggy animations.
So I resorted to directly manipulating elements' styles, which is
a lot faster.

Resolves mui#411.

If a user opens the nav on a touch device, they can use the swipe
gesture they're used to to close the nav.

Technical details: I initially tried setting nav's translateX and
overlay's opacity using setState, but turns out that on mobile devices
re-rendering the component on every touchmove event is costly and
leads to laggy animations.
So I resorted to directly manipulating elements' styles, which is
a lot faster.
@hai-cea
Copy link
Member

hai-cea commented May 10, 2015

@pomerantsev Should the swipe be on the nav menu, not the overlay?

@pomerantsev
Copy link
Contributor Author

There will be slightly more code (since on touchmove we'll have to determine whether the user is trying to scroll the menu if it's long enough, or if they're swiping the nav away). Anyway, it should look better this way, so I'll make the change.

The swipe gesture can now originate over both the overlay and
the nav itself.
@pomerantsev
Copy link
Contributor Author

@hai-cea I made it so that it works when swipe starts over the nav as well. The code correctly handles the case when the user is scrolling and not swiping. Check it out.

hai-cea added a commit that referenced this pull request May 12, 2015
Add 'swipe away' functionality to the left / right nav
@hai-cea hai-cea merged commit 865cd9b into mui:master May 12, 2015
@hai-cea
Copy link
Member

hai-cea commented May 12, 2015

Thanks @pomerantsev 👍

@hai-cea hai-cea mentioned this pull request Jun 3, 2015
@pomerantsev pomerantsev deleted the feature/swipe-left-nav branch June 4, 2015 18:02
@zannager zannager added the package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Left Nav: Pass touch handlers through
3 participants