prateekbh / preact-material-components

preact wrapper for "Material Components for the web"
https://material.preactjs.com
MIT License
553 stars 81 forks source link

2.0 - Add gesture support to drawer #1251

Closed prateekbh closed 5 years ago

prateekbh commented 5 years ago

We need to add support for swipe gesture to our modal drawer, because its 2019.

cromefire commented 5 years ago

Isn't there hammer.js? Or do you know something else that has that ability?

prateekbh commented 5 years ago

@developit has the script to do this. we just have to ask for it and paste it here I guess. Otherwise we can evaluate something like hammer/tocca.js

cromefire commented 5 years ago

@prateekbh I just tried hammer.js and it would also work: https://gist.github.com/cromefire/8a5e69f61d69d165f9988a63d0b78645

prateekbh commented 5 years ago

right, i'd like to take a look at @developit 's script as well as I know that comes without dependencies

cromefire commented 5 years ago

I didn't find it, so I couldn't try

developit commented 5 years ago

@cromefire @prateekbh sorry about that - it's here: https://gist.github.com/developit/a78fceed440b98e62582e4440b86bfab

The main benefit of this is that it supports dragging to open, not just swipe gesture causing an open action. Also worth noting that the code intentionally only handles dragging the drawer open because mdcweb has its own handling for swiping to close. Personally I think it'd be nice to go with my handling for both since it seems to perform a bit better on low-end devices. There's a comment at the spot where that can be enabled.

cromefire commented 5 years ago

Thanks

cromefire commented 5 years ago

But I think we should make this either opt in or opt out (I would prefer opt out; So that it is seperated from the original drawer)

prateekbh commented 5 years ago

@developit @cromefire I don't know if this is a bad or a good news but mdc-web dropped support for even closing the drawer with gesture.. 🤣 Dropped support for such basic use cases is what made us re-think our position of opnionless wrapper over mdc-web

developit commented 5 years ago

Probably good news, it was annoying to disable swipe close gestures.

cromefire commented 5 years ago

Merged into 2.0