-
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
Add mobile / touch support #11
Comments
This feature would require some additional touch event handlers and management in The challenges will be:
I did a little spike and I am not worried about performance at this stage. The current implementation is fairly light on the CPU while dragging |
At this stage internally we are targeting a few features for our desktop applications:
So those will be the focus of our internal efforts for now as they are out immediate use cases. If somebody else wants to give it a crack let me know. I did a spike and it is fairly easy to add some touch listeners and get it all going. The challenge is making it feel great for users every time |
Thanks for your work @alexreardon! Looking forward to this. |
Hi thanks for the react-beautiful-dnd plugin, good job so far. I wonder what way you are going to use for mobile dnd. On mobile the touch and move interaction is already used for scrolling. I see 3 ways:
|
We are looking at adopting a press and hold (long touch) mechanism to initiate touch dragging to avoid conflicts with normal scrolling. It is a similar pattern that is used in native devices. We are aiming to avoid providing any options for custom drag starting - similar to what we already do with mouse. We will investigate and decide on a approach that works well with the rest of the feature set and fits well in the physical metaphor we are going for. The long press seems nice because it is sort of like taking the time to pick something up. /cc @jaredcrowe |
We are hoping to look at this in the next few weeks! https://github.com/atlassian/react-beautiful-dnd/milestone/2 |
Yay! 🎉🎉🎉 |
🤞 I hope to start work on this when I return |
The event binding code Next week I will implement the touch sensor as well as ensuring all the old tests pass and that new tests are written for the new behaviour and touch sensor. Note: this is an internal change and the api will remain the same |
On top of the amazing work, thank you for these status updates. I, as someone interested in this feature, appreciate being in the loop about this progress. |
Yes thank you @alexreardon and for the amazing library, your hard work, and updates! This will be very helpful :) |
Glad you find them useful @mostafah @trevordmiller - I was not sure if people were interested |
@alexreardon these updates are super helpful, cant wait to try out the mobile version. This react component is one of the best Ive seen, awesome job ✨ 🙌 |
I am getting closer. I now have it working on latest mobile chrome, safari and firefox on ios11 🤘. In order to manage expectations I want to call out that this initial release will not support scrolling / auto scrolling. This means that when a |
Things move forward and then backwards. The goal is to create an experience that feels great while also respecting the standard touch interactions as much as possible. Here is some in progress documentation: Understanding intention: tap, force press, scroll and dragWhen a user presses their finger (or other input) on a
|
You can have a play with the new touch support here. Be sure to look on your touch device |
Hey Alex, tried on a Pixel on Android 8.0.0. When unscrolled I have to hold for a while before moving or it causes a refresh. When scrolled down I cant seem to move at all. I'll show you tomorrow if you like. :$ |
Great. It works very good on iPhone (Safari on iOS 11.1, iPhone 7). The only problem is that I can only scroll with the blue area. Swiping over the cards does not do anything. I’m not sure if that is expected for the first version or not. |
I was able to long press, then start moving, but instead it scrolled the list below the card. A lot of times the long press doesn't grab the task, just selects it. Android, Google Chrome. |
Drag start and scroll: we need your help!We are trying to make a decision about how to start a touch drag. There are two primary options which would be great to get your vote on. Each option will get its own comment below. To add a vote add a 👍 reaction to the comment. The votes won't be strictly binding - but it will be a great opportunity to see what other people think. Also, if you have other suggestions or would like to comment feel free to do so. ProblemWhen a user puts their finger down (or some other touch input) we need to opt out of native scrolling. Unfortunately this decision needs to be made up front and we cannot opt back into native scrolling after this initial press. Option 1: don't start drag if user is trying to scrollIf the user moves their finger beyond a threshold within a small period of time we can safely assume they where trying to scroll rather than drag. So we do not start a drag. However, this can confuse the user as the interface can feel unresponsive as they are trying to native scroll but we have already opted out of native scrolling. Option 2: start a drag on scroll attempt
If the user moves beyond a certain threshold (regardless of time): start a drag. This means that even if a user was trying to scroll: a drag will start. This might be annoying as the user may have been intending to scroll - but at least something will happen (a drag) rather than nothing in option 1. Given that we need to opt out of native scrolling I think this is the best option. Also, keep in mind that once auto scrolling lands this experience will not be as bad. Cheers |
Vote: option 1 don't start a drag is a user is trying to scroll |
Vote: option 2 start a drag on scroll attempt |
I am a little confused, would both options allow us to implement something like trello has in their mobile experience? (They've got both scrolling the lists and dragging the tasks) |
@hakunin this has to do with drag initiation. Once auto scrolling is supported then you will be able to scroll no worries |
Also, Trello's mobile web experience does not have card drag and drop |
Ah, I was looking at their app, hoping its the same. |
Yeah native is a little different. We can only achieve what the browsers / web standards let us 👍 |
@lukebatchelor @hakunin the experience on andriod is not great atm. I will be looking into it when I get more time |
I have now swapped over to option 2 and it feels much better. @hakunin @lukebatchelor I have added some improvements for android - please give it another go! |
It's perfect Alex! The vibration is an awesome touch! (No pun intended??) |
Great work on this! I’m trying to follow along but I’m missing a proper understanding of the interaction with native scrolling. I think the reason for opting out is that we want the page to stay fixed (i.e. not scrolling) so that the Draggable is moved relative to the page rather than moving with it, is that right? I’m also curious out the method of opting out of native scrolling, and your thoughts on an approach like https://stackoverflow.com/a/17159809. I also don’t know what the ideal state of starting a drag should be, whether it’s instant, force touch, touch and hold, or something else, and if you’re aiming to make the library opinionated and bake in support for one behaviour, or if you’re aiming to have it unopinionated and configurable. |
@bradleyayers we cannot use native scrolling as the direction that a user moves an item to reorder it is often the different to the scroll direction for touch devices
Yes, we are opting out so the page stays fixed - at least until we support auto scrolling. The library will be opinionated - the idea is to interfere as little as possible with standard browser interactions while designing a drag and drop interaction that feels natural. |
These styles are now baked into // These styles are applied by default to allow for a
// better touch device drag and drop experience.
// Users can opt out of these styles or change them if they really need too
// for their specific use case.
type BaseStyle = {
// A long press on anchors usually pops a content menu that has options for
// the link such as 'Open in new tab'. Because long press is used to start
// a drag we need to opt out of this behavior
'-webkit-touch-callout': 'none',
// Webkit based browsers add a grey overlay to anchors when they are active.
// We remove this tap overlay as it is confusing for users
// https://css-tricks.com/snippets/css/remove-gray-highlight-when-tapping-links-in-mobile-safari/
'-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
// Added to avoid the *pull to refresh action* and *anchor focus* on Android Chrome
touchAction: 'none',
} |
Thinking about this a bit more, I suppose https://stackoverflow.com/a/17159809 would only be useful if we wanted to go in the direction of "long press to lift draggable" UX. As in touch events would initially scroll the page, but if the user did not scroll beyond a small distance in our long-press-to-lift-duration, page scrolling would be "turned off" (by Basically it would be #1 but without the following, because the opt-out wouldn't happen up-front:
I think I'm still missing something though, because this isn't the approach you're going with. Is it:
|
@bradleyayers it is a little hard to follow. Here is my attempt to explain it a little further:
We now use the two following methods to check if a drag starts:
We also do a lot more work to ensure:
The decision was between whether we do nothing on a scroll or if we start a drag. Given that doing nothing sucks and feels broken we start the drag. The complication is the initial one time opt in / out decision. Hopefully that provides some more information for you :) |
Another plus for the approach that you chose: it makes sense with custom drag handles too. When the items have drag handles in them, dragging by drag handle should always work and I’m guessing that scroll works by swiping outside of the drag handle. This is exactly what users expect. |
@alexreardon now the demo works without issues. It would be nice if the task could highlight when I tap it (even before I start moving) because now it feels like there is a lag in the phone's response because of the movement threashold. |
You are welcome to patch the event handlers to add a selected state but it will not come out of the box with the library. Tap has particular meanings such as navigation that we do not want to overwrite (although you are welcome to) |
Thanks everyone in your encouragement getting this across the line! 🤘 Closed by #165 |
Currently the library only supports keyboard and mouse dragging. It would useful to add touch support so that it can be used on touch devices (eg phones and tablets)
The text was updated successfully, but these errors were encountered: