Code Monkey home page Code Monkey logo

Comments (5)

martinpengellyphillips avatar martinpengellyphillips commented on June 2, 2024 2

Thanks for the kind words.

The logic you see in dnd-kit is similar to what I had before (see the example code at the top of this issue). However, I encountered some issues with it and will rethink the approach. Hopefully the overall improvements to the library I've made since will make this easier to solve :)

from solid-dnd.

martinpengellyphillips avatar martinpengellyphillips commented on June 2, 2024

For reference, this was the previous 'vertical' algorithm:

  const sortedTransform = (): Transform => {
    const delta = noopTransform();
    const resolvedInitialIndex = initialIndex();
    const resolvedCurrentIndex = currentIndex();

    if (
      !anyDraggableActive() ||
      resolvedCurrentIndex === resolvedInitialIndex
    ) {
      return delta;
    }

    const draggableId = dndState.active.draggable!;
    const draggableInitialIndex = sortableState.initialIds.indexOf(draggableId);
    const draggableLayout = layoutById(draggableId)!;

    if (draggable.isActiveDraggable) {
      const droppableId = dndState.active.droppable!;
      const droppableLayout = layoutById(droppableId)!;
      if (resolvedCurrentIndex > resolvedInitialIndex) {
        delta.y = droppableLayout.bottom - draggableLayout.bottom;
      } else {
        delta.y = droppableLayout.top - draggableLayout.top;
      }
    } else {
      if (resolvedCurrentIndex > resolvedInitialIndex) {
        const leadingId = sortableState.initialIds[draggableInitialIndex - 1];
        const leadingLayout = layoutById(leadingId)!;
        const leadingGap = draggableLayout.top - leadingLayout.bottom;
        delta.y += draggableLayout.height + leadingGap;
      } else {
        const trailingId = sortableState.initialIds[draggableInitialIndex + 1];
        const trailingLayout = layoutById(trailingId)!;
        const trailingGap = trailingLayout.top - draggableLayout.bottom;
        delta.y -= draggableLayout.height + trailingGap;
      }
    }

    return delta;
  };

from solid-dnd.

alllex avatar alllex commented on June 2, 2024

Very much looking forward to this!

Currently, it's the only thing that seems to be not working for me. Here is how dragging looks for the variable-sized sortables with the flex flex-row items-center gap-1 Tailwind styles for the container.

Screen.Recording.2022-09-24.at.00.45.30.mov

from solid-dnd.

JoleMile avatar JoleMile commented on June 2, 2024

Same here. Everything else is working great, but this makes things look quite ugly at times.
Haven't looked into this much, but could we steal some logic from here https://master--5fc05e08a4a65d0021ae0bf2.chromatic.com/?path=/story/presets-sortable-vertical--variable-heights maybe?

Would love to see this "fixed" soon.
Thank you for making and maintaining this library.

from solid-dnd.

cheechqt avatar cheechqt commented on June 2, 2024

Hey. Lib is wonderful, but this issue is the first thing that catches your eye. Has anyone found any solution?

from solid-dnd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.