Giter Site home page Giter Site logo

Comments (7)

TahaSh avatar TahaSh commented on August 22, 2024 2

@Danivalldo Thank you for testing! Two solutions come to mind:

  1. Only swap after the user stops the cursor at a specific slot. I'll detect this based on the cursor's motion.
  2. Allow the developer to specify a drop target within the slot. This way, even if the cursor is on the slot, it won't swap until it's hovering over the target.

I think both options could be useful in different scenarios. I'll need to do some testing to ensure they provide a good user experience. I'll let you know when something is ready! Thanks!

from swapy.

TahaSh avatar TahaSh commented on August 22, 2024 1

@Danivalldo I've added a new config option in v0.1.0 called continuousMode. If you disable it, the swapping will only happen if the user stops the cursor. You can disable it like this:

createSwapy(container, { continuousMode: false })

Let me know if you have any questions!

from swapy.

TahaSh avatar TahaSh commented on August 22, 2024

@Danivalldo Thank you! I'm really glad to hear you found it helpful. The library should behave as described in your "Desired Behavior" by only swapping the two elements without affecting others. However, if the cursor hovers over other elements while dragging, it will also swap them, which results in the "Current Behavior." Could you please test and confirm if that's the case? Thanks!

from swapy.

Danivalldo avatar Danivalldo commented on August 22, 2024

Hello,

Thank you for the quick response and the clarification. I tested the library again as per your instructions. Here are my observations:

Test Setup:

Initial setup: [A, B, C, D, E]
Drag 'A' to the position of 'D'

Steps Taken:
Dragged 'A' directly to the position of 'D' without hovering over any intermediate elements.
Dragged 'A' to the position of 'D' while intentionally hovering over 'B' and 'C'.

Results:

When dragging directly to 'D', the library swaps only 'A' and 'D' as expected: [D, B, C, A, E].
When dragging and hovering over 'B' and 'C', the library moves 'A' through the intermediate positions, resulting in: [B, C, D, A, E].
It appears that the second behavior is triggered when the cursor hovers over other elements during the drag. This is consistent with what you described.

Feedback:
The current behavior makes sense given the implementation, but it can be challenging to avoid hovering over intermediate elements in some layouts. A possible improvement could be to add an option to disable swapping during hover or to lock the swap behavior strictly to the initial and final positions, regardless of intermediate hover actions.

Please let me know if there's anything specific you would like me to test further or if additional details are needed.

Thank you for your support and the great work on this library!

from swapy.

Danivalldo avatar Danivalldo commented on August 22, 2024

Thank you for considering these solutions! Both ideas sound great and could be very useful. I appreciate your efforts to improve the library. Looking forward to testing the updates when they are ready!

from swapy.

Danivalldo avatar Danivalldo commented on August 22, 2024

Hello,

Thank you for the update! I’ve tested the continuousMode option, and it works perfectly in my project. I appreciate your quick implementation of this feature.

Best regards,

from swapy.

TahaSh avatar TahaSh commented on August 22, 2024

@Danivalldo Really glad to hear that! Thanks!

from swapy.

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.