Forum Discussion

ArminBaghaei's avatar
ArminBaghaei
Community Member
2 days ago

Storyline 360 drag-and-drop issue: object moves away from cursor after state change

Hi everyone,

I am having an issue with a drag-and-drop interaction in Articulate Storyline 360.

I have a draggable object with two states:

  • Normal: approximately 6 × 48 px
  • Drop Correct: approximately 1 × 328 px

When the object is dropped correctly, its state changes from Normal to Drop Correct, so it appears as a full-height installed membrane.

Later, I want the user to drag the material back to its original position. When the user starts dragging the object and I change its state from Drop Correct back to Normal, the visible object is no longer under the mouse cursor. There is a noticeable distance between the cursor and the object.

What I would like is:

  1. When the user starts dragging the dropped object, it changes back to the Normal state.
  2. The centre of the Normal-state object should immediately appear under the mouse cursor.
  3. The user should then be able to drag it normally back to its original drop target.

Is there a native Storyline method to reset the drag anchor or make the object's centre align with the cursor after changing states?

If not, is there a reliable workaround using separate objects, triggers, or the Storyline JavaScript API?

I have attached screenshots/video showing the behaviour.

Thanks.

10 Replies

  • ArminBaghaei's avatar
    ArminBaghaei
    Community Member

    Hi Ronald. I can see you are right. I think this is the only option at this point. The thing is, by doing this, I hope the users will not consider this as a limitation as we are running a playtesting. I will give it a short now. I appreciate it. 

  • ronald-hicks's avatar
    ronald-hicks
    Community Member

    Thierry's diagnosis nails it: the object's hit box stays at the Drop Correct size (328 px tall) even after the visible state switches back to Normal, so the cursor offset is computed against a bounding box the learner can't see. Since there's no native "reset drag anchor" and no supported JS hook for it, the reliable fix is to stop reusing one object for both jobs: keep the small Normal-sized object as the only draggable, and put the big installed visual on a separate non-draggable object underneath it. The learner always grabs the small proxy sitting on top of the big visual, so the anchor math never changes and there's no jump. State changes then only swap the visual underneath, never the dragged object itself.

  • Hello ArminBaghaei​ . I was able to understand your problem by reproducing it in my own file. The problem obviously stems from the significant difference in the size of your object depending on its state. When you click on the bottom (for example) of the object in the “Correct Zone” state to reposition it, you’re still moving a ‘shape’ that’s 328 pixels tall, even though it reverts to its “Normal” state, which is 48 pixels tall. This is why it seems like the cursor is pointing into thin air.

    A small piece of JS code seemed like the most promising solution, but as usual with the AI Assistant, it was a three-hour struggle with no results. I did manage to realign the object in its Normal state under the cursor as I moved it (with a few lines of code that force the object to follow the cursor), but then, when I tried to cancel that forced tracking, set the object’s coordinates to that centered position, and restore the object’s original draggable functionality: the Assistant couldn’t code it correctly (and neither could I, of course). Maybe some tech-savvy folks can help you with this.

    So, I can only offer you a small workaround—it works, but it’s just a workaround. At the same time, is what you’re looking for really essential for the success of the activity and for memorizing the information? However, I’m just like you: I like to dig into a problem when I encounter one.

    You can apply a motion path of 0 pixels and 0.1 seconds to your object and create a trigger: Move Object along this path when its state is Normal. That's it.

    As soon as you move the object out of its drop zone, it instantly returns to its original position: you don’t have time to notice that the cursor and the object aren’t aligned. That’s the workaround.

    This is better than adjusting the drag-and-drop options with “Return object to starting point…” because if you don’t release the selection on the object, you’ll still see the misalignment.

    I hope this helps.

    • ArminBaghaei's avatar
      ArminBaghaei
      Community Member

      Hi. Thanks a lot. I did try to do the same thing using the SL AL and ChatGPT. It is working only for less than a second and then it does the same thing. I mean, it can hold the dropped object for let than a second and then changes to its Normal state. I think Ronald is right. I need to use the same size objects for two the two actions... I am giving up too. 

  • ali066khan's avatar
    ali066khan
    New to the Community

    Hello, 

    or this interaction, I’d structure the triggers so the visual change happens only after the drag/drop action, rather than trying to reposition the object while Storyline is still handling the drag.

     

    A clean sequence would be:

     

    When the user drops the object on the correct target

    → Change the object to Drop Correct.

    This is the point where the installed membrane should appear.

    When the user clicks/starts interacting with the installed object

    → Change its state back to Normal.

    Put this trigger before any subsequent action that depends on the state change.

    Immediately after that state change

    → Reposition the object so its center is aligned with the pointer (if you're using JavaScript).

    Allow the normal drag interaction to continue

    → The learner can now drag the small Normal-state object back to its original location.

    when multiple triggers respond to the same event, Storyline executes them sequentially, so the order in the Triggers panel matters.

    • ArminBaghaei's avatar
      ArminBaghaei
      Community Member

      Thank you so much for the suggestion and support. I have not tried your recom but speaking from my own experience, we cannot place JSs at the end of the list. 

    • ThierryEMMANUEL's avatar
      ThierryEMMANUEL
      Community Member

      Hello ali066khan​ 

      I hadn’t seen your suggestion before posting mine. I really did try, but unfortunately, SL doesn’t allow you to place the JS trigger at the end of the sequence, regardless of the condition used to trigger it—it always goes at the beginning. So your clear sequence can’t be applied. Therefore, there’s an event missing to trigger this JS code. Unless you’d like to provide further details.

      Furthermore, this doesn’t solve the problem (THE problem) of the misalignment between the clicked object (H328 pixels even though it displays the Normal state) and the cursor.

      However, there might be a way forward.

      • ThierryEMMANUEL's avatar
        ThierryEMMANUEL
        Community Member

        Another two hours, and this Assistant still doesn't know any more than I do about how SL works. No progress, no results. I’m still running into the problem that I’m working with an H328pix shape that displays the Normal state of H48pix. The predefined states (in a drag-and-drop) apparently can’t be fully manipulated or accessed via JavaScript (I seem to recall having encountered this problem before). But if I give up on the drag-and-drop activity and use only triggers (Change the object’s state when the user moves the object onto… or when the interaction between the object and the target area ends…), I’m stuck there too. I’m giving up. Sorry ArminBaghaei​