Readit News logoReadit News
cjen · a year ago
To provide some context for this, Atlassian originally created a drag and drop library called react-beautiful-dnd. A few years ago they stopped maintaining the library, and some community forks took over (I think @hello-pangea/dnd is the most popular).

In the interim I've found https://dndkit.com a _really_ nice solution, but it's only available in React-land.

Looks like this new library was written at least in part by the same guy who wrote react-beautiful-dnd, so my hopes are high (as long as this one stays maintained...)

windowshopping · a year ago
Both the dndkit and pragmatic-drag-and-drop are great for simple use cases. If you're building something complex though, neither will cut it, nor will any other dnd library I've seen. I built a card game interface last year that involved 3 forms of droppable:

- a hand, where cards were display in a row and could be reordered

- a pile, where cards stacked and only showed the topmost card, which could be dragged off the pile

- a play area, where cards were freely arranged and overlapped each other based on which was moved most recently (and thus "on top"), and in which groups of cards could be moved as a unit via drag-select

For cases like this, these libraries prove woefully inadequate. I had to hand-write the whole thing and it was by far the most challenging front-end work I've ever done, especially since it's multiplayer.

andy800 · a year ago
To be fair, this is like saying Legos aren't appropriate for building a house or a pocket calculator isn't appropriate for analyzing a particles accelerator -- simple tools are great for their intended use case but you need much more advanced tools for complex scenarios.

With that said, I agree that emulating playing cards is tricky, I'm curious what you used. I built https://play.cheatatbj.com using ZimJS (whose web site looks kind of like a joke but is actually a very impressive animation framework).

worldsayshi · a year ago
>For cases like this, these libraries prove woefully inadequate. I had to hand-write the whole thing

Did you write it in react? This is really one of the use cases where React can become a hindrance.

pryelluw · a year ago
I’m just wrapping up a project at work with similar constraints and share the same experiences. Good library, best used for simpler use cases. Drag and drop across browsers and devices is still not a smooth dev experience. Dnd did improve it a lot and performance issues are not noticeable to the end user in our use case. Hopefully the new version that comes out continues to be as good.
pieperz · a year ago
Do you do any consulting? Would love some help on something similar? @pieperz on twitter.
stevenkkim · a year ago
Could you share a link to your game? I'd love to check it out.
alluro2 · a year ago
dndkit seemed very promising, until I realized the state of development [0], and critical performance issues if you want to use it for larger lists (individual issues linked within [0]). So it's fine if you need to use it for simple scenarios and a smaller number of items, but otherwise, it's inadequate in current state, unfortunately...The fact that the post was in Aug 2023, perf. issues still remain and there's low activity on issues in general, doesn't bode well...

[0] - https://github.com/clauderic/dnd-kit/issues/1194

brosky117 · a year ago
I also found dndkit and built a very complex/robust drag and drop form builder with it. It gave me nice abstractions for custom collision detection without worrying about the browser implementation. Highly recommended.
windowshopping · a year ago
Can you link to the form builder? I'm interested to see.
alexreardon · a year ago
Hi all,

I am one of the creators of Pragmatic drag and drop (and react-beautiful-dnd).

Thanks for the post @NeilSmith2048!

I have had a quick read over the comments on this thread, and here is some information that folks might find helpful:

- The web platform has powerful built in drag and drop functionality. Sadly though, that functionality has historically difficult to be successful with due to bugs, inconsistencies and API friction.

- Pragmatic drag and drop is low level wrapper around web platform drag and drop and is attempting to provide a fast, safe and (hopefully) easy way to successfully unlock the power of the web platform

- You can use Pragmatic drag and drop with any tech stack (svelte, vue, react, vanillajs etc) and you can use it to build _any_ drag and drop experience you like

- We have optimised Pragmatic drag and drop for performance and flexibility. It consists of a small core and lots of optional pieces. The big idea is that folks only ever need to include the code they need for their experience. Small pieces also allows folks to borrow as much as they can and only build the specific pieces they need for bespoke experiences. More details: https://www.youtube.com/watch?v=5SQkOyzZLHM

- We make it easy to attach data for external windows and applications, and to receive data from them (and you only pay code for that functionality if you want it!)

- Pragmatic drag and drop is already powering drag and drop in some of the biggest software products, including Trello, Jira and Confluence.

- We have design guidance and accessibility guidance and outputs which folks are welcome to use, or you can create your own design and accessibility solutions

- It works with multi drag. We already have multi drag in a few places in production, but we currently don't have public guidance or an example (work in progress!)

I am happy to answer questions folks might have. It's a public holiday here in Australia, so I might not be able to reply to things until tomorrow.

Cheers

ty_2k · a year ago
Thanks so much for all your hard work on both of these awesome libraries. react-beautiful-dnd (and @hello-pangea's fork) have been really nice to use. Excited to try pragmatic-drag-and-drop!
Nathanael_M · a year ago
Really wonderful. I’m working on a ~relatively~ large web app and I just wrote drag and drop off as an option for form construction and report building, but this may put it back on the table. Thanks a lot!

I did notice some pretty intense issues using the examples on mobile. Is that just an issue with the examples, or is it something more foundational?

alexreardon · a year ago
It would be great to grab some details. Probably easiest to track if you head over to the Github repo and raise an issue as we have a bug template which helps us gather the information we need to action things

https://github.com/atlassian/pragmatic-drag-and-drop/issues

sevenseacat · a year ago
I was initially pretty excited seeing this! It didn't last long though.

I found the documentation really hard to work through (no examples that don't require wading through hundreds of lines of JS/React, no API documentation?), and at the time I was looking, half the links were broken and the doc site was really, really slow.

The library says it works with any tech stack, but only lists JavaScript frameworks.

The reason we use SortableJS is because we don't have to rewrite the HTML manually as things get dragged around - from what I could glean, things like the placeholder drop line have to be added as part of your rendering template?

gnabgib · a year ago
Welcome to HN! Please Be kind. Don't be snarky. Converse curiously; don't cross-examine. Edit out swipes [0]

[0]: https://news.ycombinator.com/newsguidelines.html

jjcm · a year ago
I got to work with Alex on the precursor to this while I was at Atlassian. He's such a delight to work with. I was a prototyper at the time and I was always surprised about the types of edge cases he would come to me with - things I would have never even considered testing. There's so much work behind the scenes that happens to make these drag and drop interactions feel natural.
alexreardon · a year ago
Hey Jake. Thanks for the kind words
donatj · a year ago
We've been using SortableJS for years for similar functionality.

https://sortablejs.github.io/Sortable/

dleeftink · a year ago
Maybe I'm easy to impress, but I always stop and play around with the nested tree example when I come across Sortable. It works so flawlessly, and feels very tuned to mobile dnd. It even works to arrange (and reflow) inline spans in a paragraph! I have yet to come across this functionality in a text editor..

[0]: https://observablehq.com/@dleeftink/sortable-playground

Woovie · a year ago
I Agree, the tree is simply amazing. I had never tried sortable but felt immediately impressed there.
eyegor · a year ago
I can't get this to work reliably on mobile firefox, and I don't see any non-react examples which is strange given their value pitch is "use any front-end". Sortable works everywhere and has nice simple examples: https://github.com/SortableJS/Sortable
pjc50 · a year ago
This is off topic a bit, and not a criticism of this library or its authors, but: I do think that DnD is bad for accessibility. Especially on mobile, where it's much harder to precisely click, so the deadzone required to distinguish a click from a drag has to be much larger.

But whether it's on a mouse, trackpad, touchscreen, trackpoint, or other more esoteric system, it requires a muscle hold while doing a precise movement along another axis. And this can be more difficult and RSI-inducing. God help you if you're trying to drag on a resistive touchscreen where more force is required, too.

I feel that the copy-paste workflow of pick source -> copy -> pick destination -> paste is actually easier (and much more prevalent!) than pick -> hold AND move -> drop. It also works better in windowed systems because you can more easily interact with the window system while "holding" the thing; this is often impossible or more difficult while using DnD and having to hold down the primary button.

(some drawing tools actually recognize this by having different tools/cursors for "select items" and "move item(s)". The old Acorn Archimedes used a different mouse button (middle) reserved for DnD. I feel it could work well with a stylus with a button too. But in both those cases I would prefer "click to pick up, click to drop" to holding.)

w10-1 · a year ago
To avoid strain and accuracy requirements, iOS (and I imagine Android) support Accessibility extensions targeting drag motions - See Accessibility/Touch/AssistiveTouch.

It seems fair to have the logical gesture of a drag be provided accessibility support on a per-device basis. To the extent that any UI library is written in terms of underlying mouse clicks and locations, it would interfere with that support. So the real question is whether the UI library support for DnD can be managed using device accessibility.

DrScientist · a year ago
Totally agree - that drag and drop is over-rated.

The only area I think where drag and drop has an advantage is if you want to be precise about where you drop and thus realtime feedback about where it will drop is useful.

ie drag and drop effectively adds a mode while you are dragging - and as such you can have mode sensitive UI feedback that operates only in that mode - not so easy with cut and paste - the UI doesn't know you are about to paste.

zatarc · a year ago
Cannot believe they missed the opportunity to call it "Dragmatic".
pqdbr · a year ago
This is such a cool name that I'd open an issue and suggest the rebranding :)
fuzzythinker · a year ago
They won't even need a new logo, as they can just rotate the "p" 180 degrees.
strongpigeon · a year ago
This looks really good. Much better than react-beautiful-dnd which was sheer madness IMO. They were reimplementing most of the stuff browser does for you. Sadly I just built my own stuff on top of native browser drag-and-drop, but might look into changing to using this eventually.

The browsers inconsistencies are pretty annoying. Especially the weird Chrome stuff when you remove the draggable from the DOM during drag. Great to see their lib hiding this.