Use pointer events to enable touch support#85
Use pointer events to enable touch support#85ceddlyburge wants to merge 41 commits intoannaghi:masterfrom
Conversation
THis works for the basic example, but still wants a bit of work / thought
| Json.Decode.decodeValue | ||
| Internal.Common.Utils.decodeCoordinates | ||
| value | ||
| |> Result.withDefault (Position 0.0 0.0) |
There was a problem hiding this comment.
It would be better to return Sub.non here, rather than defauting to Position 0.0 0.0, but I couldn't get it to work.
src/DnDList.elm
Outdated
|
|
||
| Just pointerCaptureEvent -> | ||
| Cmd.batch | ||
| [ Task.perform (stepMsg << (\_ -> ResetPointerCaptureEvent)) (Process.sleep 1) |
There was a problem hiding this comment.
I don't think Task is required here, but I couldn't get it to compile any other way.
And move touch-action: none in to each example, so that when copying an example its more obvious that you need it.
Mouse doesn't require ports, so is a lot easier to integrate, but pointer works for mouse and touch.
|
Hi @annaghi , I think this is ready for review now. All the examples can now be used with touch, and I went through them all to check that they all work. There is now a There is also a Some notes:
|
|
Any update on this? <3 |
|
I haven't heard from Anna for a while, or seen her active on slack. I assume she is in the middle of something that is taking up all of her time. This works though, so you could copy / paste the code in to your app as a temporary solution? |
I think this avoids and endless loop that occurs as a race condition
|
Hi @annaghi, I've fixed that problem we saw. I think it was a race condition. Being as the pointer events are different, come in through ports and have the 'releasePointerCapture' complication, I can easily imagine that they come in a different order to the mouse events sometimes. Anyway, everything works now, and you can give it a look on my fork at: |
|
Hi Cedd, great work! I will review it in pieces, the first request is to create a Port module similar to this PR: https://github.com/annaghi/dnd-list/pull/86/files |
|
Hi Anna, the ports are already in this PR, but in Home.elm (instead of inPort.elm as in that PR you linked to), is this an important difference? |
|
Thank you for incorporating the ports into the |
|
Ok, this is done. Cheers, Cedd |
|
In the other PR I have added an example for no-touch: examples/src/Introduction/Basic_NoTouch.elm Can you please add it here too? |
|
Ah yes, I remember you asked me to do this a long time ago, and I did! But its on the other branch where we were thinking about a different way to do the ports. I've pulled it in to this branch now. |
|
Hi @annaghi, do you have any other comments? |
This works for the basic example, but still wants a bit of work / thought