Forum Discussion

JG4's avatar
JG4
Community Member
3 months ago

Drag 'n' drop issue

Hello Community - I have an issue with a project I'm working on and I was hoping someone might be in a position to help me?

I've developed a simple drag 'n' drop task for the user to complete. When the user drags the drop-item to an incorrect drop-target, the incorrect layer displaying a red cross will play. I would like this incorrect layer to play on each occasion that a drop-item is dropped on an incorrect drop-target. Instead, I have reproduced multiple versions of the incorrect layer to achieve the desired outcome. Is there a variable I could write, that repeatedly plays the incorrect layer when a drop-item in incorrectly placed on a drop-target?

7 Replies

  • Based on your current design, you would need to adjust the Layer properties.  One of the adjustments you have made already (Reset to Initial State) however, the layer does not restart since it never goes away.  You will also want to check the "Hide Slide Layer When Timeline Finishes" option.

     

     

    In the future, you may want to consider using the Drop Correct and Drop Incorrect States and deselecting the "Delay item dropstates" option.  You could generate a similar effect without any triggers.

  • Nedim's avatar
    Nedim
    Community Member

    I understand that once a drag item is dropped correctly, it should no longer be draggable. The Correct layer should appear only once for each correctly placed item.

    On the other hand, if a drag item is dropped incorrectly, it should remain draggable and allow repositioning to another drop target.

    What complicates things is that the Drop Incorrect state tends to persist even when the item is moved from one incorrect target to another — so the Incorrect feedback layer doesn’t always trigger each time it’s dropped incorrectly again.

    Moreover, if the item is moved out of any drop target entirely, it still retains the Drop Incorrect state and may trigger the Incorrect layer, even when it's dropped outside of a valid target.

    In the attached version, each drag item is set to the Disabled state once it is correctly dropped, so it can no longer be dragged again, while the Correct layer displays as expected.

    Once all drag items are in the Disabled state, the "Well Done" layer will appear.

    If a drag item is dropped incorrectly, the Incorrect layer will show, and the item will be returned to its starting position (by forcing it back to the Normal state with Motion path), allowing it to be dragged and dropped onto another valid target. This way, the Incorrect layer won't appear redundantly if the item is dropped outside a valid drop target.

    • JudyNollet's avatar
      JudyNollet
      Super Hero

      Nedim​ : Your solution is a great improvement on what I had posted (and have since deleted). 

      I haven't used a drag-and-drop in so long, and I didn't bother testing unlikely-but-still-possible situations, like if the user dropped an object outside of the targets or dragged an object that had already been correctly dropped. My bad. 🤷‍♀️

      JG4​ : I will add one note from the previous reply that I deleted: It's great that you only included the drag-and-drop slide in the file you uploaded. I also suggest that you give meaningful names to all objects and layers (and variables, if used). That will help you when programming. And it will make it easier for you and for others to troubleshoot. 

      You'll see that Nedim took the time to do that in the file he attached. 

       

      • Nedim's avatar
        Nedim
        Community Member

        JudyNollet​  You shouldn’t have deleted your solution. Without it, it would’ve been much harder for me to identify the inconsistent Drop Incorrect state behavior — especially since you clearly defined both Drop Correct and Drop Incorrect states, which wasn’t the case in the original version.

        Your version was more elegant, using only a few well-placed triggers to do the job. Since this interaction was mainly driven by the original poster’s requirements, I had no choice but to use additional triggers just to work around the Drop Incorrect state when it was no longer needed.

        Custom drag-and-drop interactions are always tricky to fix or adapt. We all use different techniques — some more intuitive than others — and it’s always a challenge to implement custom logic on top of someone else’s structure.

         I also suggest that you give meaningful names to all objects and layers (and variables, if used). That will help you when programming. And it will make it easier for you and for others to troubleshoot.  Golden advice — this should be pinned to the top of every discussion thread.