-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(sidenav): add gestures to sidenav to allow dragging the sidenav #6174
Conversation
.on('$md.dragend', onDragEnd); | ||
|
||
var style = getComputedStyle(element[0]); | ||
var sidenavWidth = parseInt(style.width); |
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.
element[0].offsetWidth
won't work better?
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.
That won't work, because the sidenav is hidden, that's why offsetWidth
doesn't work
@EladBezalel Would be great if you test the provided demo 😄 |
I've create a module that replaces the original mdSidenav with the version of this pull request for testing: |
Thanks for your work @JumpLink, but I think we should test my PR with fetching the current patch (https://patch-diff.githubusercontent.com/raw/angular/material/pull/6174.patch). There is also a nice demo from me, so you only need to build the docs. |
@devversion I tested it locally and it feels a bit weird, i assume you based on the bottom sheet code. |
What do you mean? Here a little video This even works on Android and IOS perfectly (smooth and user friendly) |
I mean, bottom sheet have this extra space to be dragged to, also as i said, swipe the bottom sheet down real quick and it will be dismissed.. |
But that makes no sense to add extra space to a sidenav (as we can see for example in the Android API 23, there was never a extra space for dragging. This will create more issues with the width of the sidenav. And the bottom sheet will close itself after dragging it a few pixels down. That shouldn't be implemented in a sidenav too. |
OK, about the width i can agree with you, but as i mention earlier bottom sheet calculate the drag acceleration and dismiss if its was a fast swipe and it should be also on the sidenav (take a look at the google store sidenav) |
@EladBezalel can you test the swipe acceleration? :) |
@devversion sure, later today I'll take a look! |
d55fbd9
to
4f644ef
Compare
Great, thanks for your time! |
4f644ef
to
fd75cd9
Compare
|
||
if (!isQuickDrag) { | ||
if (isRightSidenav) isQuickDrag = lastDistance - ev.pointer.distanceX <= -accelerationBound; | ||
else isQuickDrag = lastDistance - ev.pointer.distanceX >= accelerationBound; |
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.
wrap with brackets
also can be:
var distance = lastDistance - ev.pointer.distanceX;
isQuickDrag = isRightSidenav ?
distance <= -accelerationBound :
distance >= accelerationBound
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 will use brackets ;)
I would also change the |
3a61ee8
to
550a200
Compare
d97349e
to
d8e6f99
Compare
d8e6f99
to
15f9085
Compare
@devversion - what is the status of this PR? It appears outdated ? |
@ThomasBurleson It is not outdated - I will rebase the next days. We can better say, it's currently blocked - because once this feature is landed, the siidenav will not allow scrolling for iOS anymore. |
FYI: This PR will be deprecated and re-submitted, once #7857 has landend. |
This issue is closed as part of our ‘Surge Focus on Material 2' efforts. |
I'm currently working on the feature, which allows to drag the sidenav.
Fixes #1591 Fixes #35