25 comments

  • gavinray15 hours ago
    Funny story about drag-and-drop:<p>At my very first job, we had a weekly meeting to assign tickets and estimates.<p>Our non-technical PM wrote &quot;drag-and-drop&quot; on a whiteboard, and then my name.<p>&quot;Gavin, how long do you think this will take?&quot;<p>&quot;All week. At least. Maybe longer?&quot;<p>PM laughed, then realized I wasn&#x27;t making a joke.<p>&quot;What do you mean &#x27;all week&#x27;? That&#x27;s ridiculous, do I need to give this to someone else?&quot;<p>&quot;Well, you could, but I wouldn&#x27;t count on you getting it any sooner.&quot;<p>Appalled, he exclaims: &quot;It&#x27;s <i>just</i> drag-and-drop!&quot;<p>After 10-15 minutes of a room full of engineers trying to explain the difficulty, he gave up with an unhappy &quot;Fine.&quot;<p>The phrase &quot;it&#x27;s <i>just</i> drag-and-drop&quot; became an inside joke for the rest of my time there...
    • freecodeio15 hours ago
      I think non-tech people think that drag and drop is some sort of emergent property because you&#x27;re pressing the mouse and holding it pressed.
      • polarsanel3 hours ago
        Making something easier and more intuitive for a human is more work as always.
    • nielsbot3 hours ago
      I think the Dragology stuff actually gets to the nub of what makes interactive drag-and-drop challenging: it&#x27;s speculative live editing of a view into your model data.
    • adastra2215 hours ago
      Dumb question: why? It’s been a long time since I touched GUI code, but I thought it gave you a message with the URI to the file. How is this significantly different than file-open?
      • gavinray13 hours ago
        This was circa 2010 or so, and it was a web app. So pre-ES6 JavaScript, before React.<p>Nowadays you would just <i>&quot;npm install drag-and-drop&quot;</i> but back then you often had to hand-roll solutions.<p>If anyone can dig up an ancient library on GitHub for drag-and-drop back in those days, I&#x27;d imagine it would be several thousand lines long, not to mention the absolute nightmare that testing something like this with a proper framework and accompanying testing library.
        • adastra2213 hours ago
          Ah, I was thinking desktop applications.
          • Xirdus8 hours ago
            Desktop app drag and drop is also a nightmare. Various frameworks can make it easier or harder, but regardless of what you choose, you have about 5 different states your draggable is in, and all of these states have at least 2 transitions to other states, and all your drop targets have to handle mouse-in&#x2F;mouse-out&#x2F;drop-end events, and those events need to expose enough data about the dragged object so that every drop target can not only execute the drop, but also tell you whether dropping is allowed without consuming the data.<p>It&#x27;s not insurmountable by any means, but it does have enormous inherent complexity compared to almost every other UI action there is.
        • pcthrowaway7 hours ago
          2010 I&#x27;m pretty sure you had jQuery plugins to simplify drag&amp;drop for a lot of use cases. But of course, if your use case was outside of the basic ones easily handled by a jQuery plugin, good luck!
        • anonymous90821313 hours ago
          Hit-test where the mouse-down event is fired, hit-test where the mouse-up event is fired. What the hell do you need a library for?<p>&gt; If anyone can dig up an ancient library on GitHub for drag-and-drop back in those days, I&#x27;d imagine it would be several thousand lines long,<p>I bet, the JS devs who do write code overcompensate for the ones who can only stitch together libraries. I suppose because the expectation is that the library consumer is incapable of writing their own code extending it, so the library itself must support every possible combination of use cases for a million different users, even though the code any individual consumer actually needs is more like 100 loc.
          • gavinray12 hours ago
            <p><pre><code> &gt; What the hell do you need a library for? </code></pre> On the frontend, you have to re-calculate the display state for all the possible drop positions, in-between transitions, and drop-end-snap-back.<p>Think of a grid of cards, and all the possible drag, hover, and drop state transitions it can be in with any other card, and the animations required to make it look nice<p>Now also consider that you need to persist the final state on the backend, and handle things like rejection, cancellation, failed updates&#x2F;errors.<p>It becomes a massive state chart and web of complexity
            • anonymous90821312 hours ago
              I mean, maybe we&#x27;re missing context here. Is that what your boss was actually asking for? 99% of web applications (or, hell, desktop applications) don&#x27;t have ultra-interactive, fully-responsive-animation drag-and-drop. If he was asking for functional drag-and-drop and the team was implementing top 1% cosmetic drag-and-drop, that&#x27;s certainly one avenue for a mismatch in expectations.
              • FearNotDaniel3 hours ago
                I think people are talking about two different kinds of drag-and-drop. There is dragging external items (files from the OS, for example) onto the app surface from outside. And there is a list of items, each with its own UI component, being dragged <i>within</i> an app to either change sort order or otherwise change data state. Both complex, and have a lot in common, but many comments here seem to be talking about one or the other without specifying.
          • dofm10 hours ago
            What does that look like mid drag, and how?<p>If you are dragging <i>within</i> the page, then the draggable “ghost” is your problem too (it’s not automatic). As is deciding whether the ghost should affirmatively snap out of and into the source and target containers (that is, whether the destination container should appear to “make room” for the ghost at some transitional point), whether there’s a transition on that, etc.<p>Drag and drop in desktop non-web GUIs have all sorts of visual affordances that users expect for consistency that are your job in HTML.<p>I was once quite up-to-date with raw frontend work and I tried to implement this; it’s actually not trivial.
            • anonymous90821310 hours ago
              &gt; draggable ghost<p>Okay, you&#x27;ve added a requirement. Poll the current cursor position after the first hit-test sets the dragging state and call a function to render your object with X% opacity at a higher Z level than anything else. Your 30 minute job has become a 60 minute job.<p>&gt; As is deciding whether the ghost should affirmatively snap out of and into the source and target containers (that is, whether the destination container should appear to “make room” for the ghost at some point), whether there’s a transition on that,<p>Most applications don&#x27;t go this far, including your operating system like Windows that sets baseline UX expectations, so you&#x27;re well beyond the default expectation for drag-and-drop. If someone asks you to implement drag-and-drop without specifying they want all the bells and whistles, and you respond it&#x27;s going to take you a week because you&#x27;re planning to go all-out beyond necessary business requirements, they&#x27;d have a valid reason to be like &quot;WTF mate?&quot;. Also this is still pretty paltry and not a week&#x27;s worth of work.
              • penteract9 hours ago
                z-index is a CSS property, but doesn&#x27;t work reliably on the web to always put something on top (IIRC, it positions it within its stacking context - there may be many nested stacking contexts). You need to somewhat carefully make a copy of the dragged DOM node (assuming the thing being moved is all in one DOM node), put it into a separate div which can be in front everything you want it to be in front of; and hide the ghost when you want to do hit testing for the drop. Also, you need to actually think about what you want the drop interaction to do wherever it might land (this last step could scale in complexity indefinitely depending on the webpage).
              • dofm10 hours ago
                Did you ever actually do this work?<p>Do you remember what browser testing was like?<p>Remember the quirks of browsers’ different understanding of transparency, of z-index, of events, of DOM compliance?<p>I think the suggestion that getting it right could take a week in the context of a particular application is actually not particularly hyperbolic.<p>Mind you, I was doing cross-browser testing long enough ago that I am one of those people who can say they independently invented AJAX in-house.
                • anonymous90821310 hours ago
                  I&#x27;ve done it a dozen times in gamedev, where interfaces and interactivity are routinely built from scratch without any help of a framework. I didn&#x27;t work on web applications in 2010, but even with the clusterfuck that the web is I find it difficult to believe it was <i>that</i> hard to do.
                  • dofm10 hours ago
                    It could be absolutely exasperating, even in 2010 (especially then since browser support for touch events was still shaking out).<p>The problem is that even without a framework, you didn’t have a blank slate (which would have been better). You had a moving target of blank slates, you had platform differences, you had drag vs touch-drag, entrenched older browsers and the simple frustration of testing on an array of real devices, all sorts.<p>Now, if you were talking about 2015, then it starts to get a bit flatter.
                  • gf0006 hours ago
                    From scratch is often way easier than in a browser-compatible way.<p>It&#x27;s no accident that after certain complexity people will just go for a blank canvas (afaik Google docs is also canvas-rendered).<p>The problem is that for drag n drop you mostly want to support normal dom.
                  • onion2k5 hours ago
                    <i>even with the clusterfuck that the web is I find it difficult to believe it was that hard to do</i><p>This is how I feel about global illumination. Game devs claim it&#x27;s hard but they&#x27;re just noobs who don&#x27;t know how to write a lighting shader.<p>I&#x27;m not a game dev, but it <i>can&#x27;t</i> be that hard.
                  • bryanrasmussen8 hours ago
                    so in short, you haven&#x27;t done &quot;this&quot; work, you have done work in another field with different technical limitations that also has the concept of &quot;drag and drop&quot;.<p>serious question, why, when people from a field you are unfamiliar with tell you that something has particular constraints in that field, do you confidently assert that you know better?
      • sn0wleppard3 hours ago
        Dragging UI items around on a page is very different problem to dragging an external file onto a page
      • ehnto12 hours ago
        I built a drag and drop content CMS&#x2F;website builder in native Javascript years ago. The browser APIs are really cumbersome. The other issue is more UX than technical, there are lots of questions to answer. What are you dragging, what is it hovering over actually, what is the intention once it&#x27;s dropped etc.
      • hdjrudni7 hours ago
        Drag-and-dropping a file directly on the HTML `&lt;input type=&quot;file&quot;&gt;` file picker works with no code&#x2F;JS.<p>If you want to splash up the &quot;drop here&quot; thing it&#x27;s a frickin nightmare. The events don&#x27;t fire when they should (e.g. mouse leave doesn&#x27;t fire so it gets stuck, or you get duplicate events or missing events) so you get a bunch of flicker unless you do a bunch of debouncing and fail safes to cover all the browser quirkiness. And this is the easy drop-a-file scenario.<p>Doing all the stuff shown in <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=l7v-UwpsEbk" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=l7v-UwpsEbk</a> I&#x27;m not sure I&#x27;d even know where to begin.
      • mcculley14 hours ago
        There are more possible actions than opening files.
    • cosmic-dancer3 hours ago
      While it&#x27;s a wrong assumption, I don&#x27;t really think it&#x27;s dumb for a non-technical person to assume this is fast to implement, and I don&#x27;t think it&#x27;s some epic own that he offered pushback on this even though he was wrong.
      • polarsanel3 hours ago
        &gt; do I need to give this to someone else<p>If said this way he was a jerk. So good on em for making a joke.<p>&quot;Why would this take so long?&quot; would be better.<p>My guess like most things &quot;you wanna retrofit audio and data cabling to your house. Find an electrician who can do that in an hour. Yes it is just wires&quot;.
        • cosmic-dancer3 hours ago
          &gt;do I need to give this to someone else<p>Could mean &quot;I didn&#x27;t know you had so much stuff on your plate that takes precedence&quot;. You&#x27;re giving 0 benefit of doubt to a PM who in my opinion was right to push back because for a non-technical person it&#x27;s not easy to grasp why drag and drop should be so much harder than other similar impact features.
          • flohofwoe1 hour ago
            &gt; to a PM who in my opinion was right to push back because for a non-technical person...<p>Ah and there&#x27;s the rub. Why should a PM of a software project even be a &#x27;non-technical person&#x27; (because tbh what&#x27;s even the point, how would a &#x27;non-technical&#x27; person even be able to evaluate technical decisions and their implementation?). And even for multi-disciplinary projects like videogames it&#x27;s not too much to expect that the project manager has at least a basic understanding of all crafts that work on a game.<p>E.g.. there&#x27;s nothing more useless than a PM that&#x27;s just pushing task bars around in JIRA to make them fit into the next sprint.<p>...and also: would you fly in a plane, or drive over a bridge that was built under supervision of a &#x27;non-technical&#x27; PM? (I know I know... since the Boeing disasters that question is rhetorical, most people don&#x27;t seem to care)
            • Muromec1 hour ago
              PM has to be nontechnical so they can manage the symptoms. PM also has to be technical to not trigger the worst of
    • ChrisMarshallNY2 hours ago
      One of the more complex early modules that I wrote, was an engine for selecting a crop of an image in a scanner control plugin.<p>It was <i>crazy</i> complicated.<p>Simple is not simple.
    • coffeeenjoyer4 hours ago
      Obligatory clip <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=XpNdGvbwtf0" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=XpNdGvbwtf0</a>
    • giwook13 hours ago
      I love when non-technical people think they know better than the technical people about technical things...
    • timcobb15 hours ago
      good thing you had backup. rough hahaha.
  • btown16 hours ago
    Oh, this is very, very cool, and very, very timely!<p>Paper here: <a href="https:&#x2F;&#x2F;declarative-dragging.github.io&#x2F;D2.pdf" rel="nofollow">https:&#x2F;&#x2F;declarative-dragging.github.io&#x2F;D2.pdf</a><p>IMO one of the remaining gaps of agentic coding is that it&#x27;s hard for even multimodal LLMs to check interactive motion effects for correctness and &quot;feel.&quot; Like, sure, they can take screenshots of a few snapshotted states, but in terms of how things react as underlying nodes move and (potentially) reflow. How do you QA the feel of moving your wrist rapidly in the context of nested zones?<p>The answer is that you avoid the need to: you have a (nearly-provably) <i>correct</i> foundation that ensures that behavior is predictable regardless of state, and just render accordingly.<p>The paper&#x27;s approach is incredible here: simultaneous optimistic rendering of multiple possible states, and a composable algebra (a small combinator language) over how drop zones and distance are derived - allowing for an extremely high-level interface in practice. Everything feels snappy and <i>right</i>, and the code you write is about as minimal as you can get - though the paper notes that state management is somewhat complex. But this seems solvable!<p>Once this is ported to HTML, it&#x27;ll become an incredible part of the modern dev toolkit. I&#x27;m very excited for what this means.
    • disconcision16 hours ago
      i have a basic html version working with solid, using basically the FLIP technique to get the measurements. dunno in what form we might try to release it though, its a bit awkward to generalize over existing frameworks
  • tablatom4 hours ago
    Imagine an agentic coding system with a good memory implementation. It&#x27;s prompted to build an app with sophisticated drag-and-drop features. And then another one... After twenty such apps it realises there must be better way and comes up with declarative dragging.<p>It&#x27;s pretty clear to me how far current models are from this being real. I&#x27;d say it&#x27;s a good example of how AGI it not upon us, despite what the big labs are claiming.<p>Even the remarkable mathematical achievements are in some ways brute-forcing in a limited space. The space of &quot;how could we build this better&quot; is in an entirely different category of scale.
    • adamddev12 hours ago
      Exactly. There&#x27;s a big difference between filling in a function or a proof by searching and brute-forcing across existing lemmas or functions and creating truly novel ideas and solutions.
  • sourdecor16 hours ago
    I think this is a really cool project, but I also really appreciate the introduction to Hazel[0].<p>[0]: <a href="https:&#x2F;&#x2F;hazel.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hazel.org&#x2F;</a>
    • jauntywundrkind14 hours ago
      Hazel is such a god tier system, all the respect. Taking programming and making representing things in this live system good is such a huge bridge to a better programming, programming that welcomes the world in.<p>In huge &quot;Stop Drawing Dead Fish&quot; &#x2F; &quot;Stop Writing Dead Programs&quot; ways. Which I&#x27;m such a fan of. Asked Astra to chase down references on this a couple weeks ago, quite enjoyed the result. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5634662">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5634662</a> <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33251799">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33251799</a> <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33270235">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33270235</a> <a href="https:&#x2F;&#x2F;chatgpt.com&#x2F;share&#x2F;6aea25b4-e294-83e9-b925-431bb13b00c0" rel="nofollow">https:&#x2F;&#x2F;chatgpt.com&#x2F;share&#x2F;6aea25b4-e294-83e9-b925-431bb13b00...</a><p>Thanks for the mention. I ran across Declarative Drawing &amp; I really want excuses to use this. But I don&#x27;t remember Hazel from the video I watched in it!
  • gobdovan15 hours ago
    Appreciable, but what is the novelty exactly? The API design? I see the paper doesn&#x27;t call out Sketchpad or any of Ivan Sutherland&#x27;s work anywhere in the paper, neither ThingLab or Juno(-2). They do call out Apparatus, which already introduced speculative rendering. The work also doesn&#x27;t seem to generate valid transforms, which you have to supply yourself. Discovering valid transforms or solving a more general inverse rendering problem would have been much cooler research.
  • edflsafoiewq9 hours ago
    The Twisted Trees example is really cool. I would not have been able to implement it that well. After playing with it, I think at the most basic the underlying principle is:<p>&gt; Write your interface as a function of continuous variables, ui = ui(x1,x2,...) = ui(X). When dragging an element, compute the barycentric coordinates λ₁,λ₂,λ₃ of the cursor between the three nearest dropzones. Then render by interpolating the ui parameters between their values at those three dropzones, ui(λ₁X₁ + λ₂X₂ + λ₃X₃).
  • codedokode13 hours ago
    Interesting idea, but look too complicated for me. What if there are 1000 places where an element can be dropped? What if we select and drag several elements at a time?<p>Also this approach seems to introduce new complicated concepts like &quot;composables&quot; and even a DSL. Probably writing custom code for Drag-and-drop would be easier that figuring out how this works. I read the page and did not understand much. For example, this phrase is difficult to understand: &quot;Rather than programming all that visual behavior directly, you simply say, for each element you want to make draggable, which future states of your application dragging it should lead to.&quot;. Not &quot;simply&quot; at all. Writing new code would be easier especially with LLM.
    • nostrebored12 hours ago
      The idea is that you can describe the predicates, producers, and goals. If I’m understanding correctly. This is how a ton of stuff works: excel, your IaC, etc.<p>Here the goal can be a render state and it is the solvers problem to figure out what should be there.<p>So you define these things very atomically, but the behavior automagically finds a valid render state (usually through converting things into a standard planner or solver language, haven’t dived into this repo yet)
  • amelius16 hours ago
    Does this also work when the search space becomes large?<p>I fear this might lead to an exponential blowup.<p>(The examples shown are all tiny)
    • pratikdeoghare7 hours ago
      I suspect this might almost never be a problem. Because say there are n things on the canvas and they have occupied n slots, you lift one of them and want to drop it somewhere, there are only n spots to drop it to. This gives only n next states, even though there are n! permuatations. You have to drag and drop again to reach some other state.
      • pratikdeoghare7 hours ago
        One artificial example that can generate exponential number of states is this.<p>You have a list of sets and their subsets below them shown on screen. Now you take one element from one of the sets and add it to another set want things updated, this will trigger exponential computation. Since we (human) can&#x27;t really visually look at all the exponential subsets anyway it will be not a very useful visulalization.<p>So exponential state space will be a problem only in the cases we don&#x27;t care about it. Even then we could choose only few of the states by some criteria.
    • jnpnj14 hours ago
      I didn&#x27;t read the paper yet, but do you they do space partitioning based on events direction ?
  • disconcision16 hours ago
    an author here (andrew). down to answer questions though it might be a bit until i get to them
    • sebmellen16 hours ago
      All I have to say is thank you for doing this! This is truly super cool. It’s a rare kind of gem to see thoughtful work like this in our new AI era.
    • rao-v15 hours ago
      Someone else asked something similiar but basically, how does &#x2F; should this work when candidate drop targets are many e.g. when dragging a first or second rectangle onto a page in Figma when no relationships have obviously been set.
      • disconcision11 hours ago
        not 100% sure this is what you&#x27;re asking but for continuous degrees of freedom i.e. numeric model parameters we have the &#x27;vary&#x27; operator, which is used in all our canvas-type examples. more in the paper (section 5 under the numerical optimization header). in the trivial case this allows for unconstrained positioning
    • terabytest16 hours ago
      Out of curiosity, does your library support physical springs for animation between states? That’d be a great touch.
      • disconcision11 hours ago
        so far the library is history-independent wrt transitions, which is a nice simplification but does preclude more physics-y interactions.
    • michalsustr15 hours ago
      Very cool demo! One idea I had in the back of my mind is extending grammar of graphics for interactive visualisations. What you did might be a good way how to approach this! Did you think about doing something like this btw.?
    • DonHopkins1 hour ago
      [dead]
  • kkotak17 hours ago
    Nice work! Good to see that someone is still working on making the Human Computer interface that has been around for while and used extensively in many applications more human. Thank you.
  • ramblurr2 hours ago
    Is there any hope this could be turned into a vanilla js library and not attached to a particular SPA framework?
  • cootsnuck15 hours ago
    Very neat, looking forward to playing around with this. We are sorely in need of of more exploration into UX&#x2F;UI, HCI of the current era of digital tools.
  • jy1489815 hours ago
    <a href="https:&#x2F;&#x2F;omrelli.ug&#x2F;g9&#x2F;gallery&#x2F;" rel="nofollow">https:&#x2F;&#x2F;omrelli.ug&#x2F;g9&#x2F;gallery&#x2F;</a>
    • meindnoch15 hours ago
      Precisely what came to my mind.
  • dwoldrich9 hours ago
    This API feels as significant to me as Reactive Extensions did when Netflix first debuted it. Thank you for this research! I have a lot to think about!
  • O_H_E16 hours ago
    Anyone have an idea of what stack&#x2F;technique would be used to accomplish a task that this is widely superior for. The work seems cool but I&#x27;m having trouble imagining what is it replacing.<p>Edit: nvm, answered by the Background section of the paper
  • nostrebored12 hours ago
    We will continue to reinvent dataflow and planning problems until the end of time; you will be surprised how many fundamental pieces of software use this paradigm
    • gobdovan10 hours ago
      technically all of them since hardware itself is basically a dataflow system
  • leecommamichael16 hours ago
    Speculative rendering sounds awfully expensive.
    • pyrolistical15 hours ago
      It’s just rendering? I don’t see why it would be more expensive
      • leecommamichael10 hours ago
        Rendering in this context means producing an element tree, or a textual description of one, which is capable of firing off many little (slow) allocations. The implication being that this will not scale to a large number of nodes without slogging the machine unduly.
        • chii8 hours ago
          If it&#x27;s in memory and off-screen, i think it won&#x27;t be that slow even for many elements. The actual issue might be the garbage collection pauses, which might become noticeable.
  • fitsumbelay13 hours ago
    all links and buttons in document header are also draggable demonstrations of the concept. very cool
  • Darky18 hours ago
    Fantastic work! The interactive demos are incredibly satisfying to play with, visually delightful, and genuinely educational.
    • petters18 hours ago
      Agreed. It’s really good!!
  • gandreani17 hours ago
    This is revolutionary! I wonder if there&#x27;s any similar prior art.<p>The Hazel programming env is dope. I can already imagine using it to explain refactorings to new programmers.<p>The twisted tree diagrams is also really neat. Is that a new idea as well? I got the beginnings of an idea where it might be a good diagram to display tangled code paths.
  • gitgud16 hours ago
    Wow that is an elegant way to do it. This could create a renaissance of drag n drop interactions for the web
  • hermannj31417 hours ago
    It is nice to read a coding article.<p>Very nice work
  • totetsu8 hours ago
    related. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49858513">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49858513</a>
  • diligly15 hours ago
    Good work
  • dogscatstrees15 hours ago
    Drag-and-drop is a user interface feature. More often we need drag tools for DAG (Directed Acyclic Graph), which is an execution architecture. Most work involves dependencies: something must happen before something else can happen. I didn&#x27;t see DAG here.