Reset Drag and drop inside symbole


I'm trying to reset a somewhat peculiar drag and drop (because it also displays text when dropping and all is inside a symbole, i tried a function that I saw on the forum and that I named "restart" when the we click on button2 but it doesn't work :frowning:
How can I do it please? I put the basic document as an attachment. Thank you if someone can help me finalize my project ! :slight_smile: (853.9 KB)


I wanted to start from the "dragAndDropPlusResetPlusOffset" document to do the same on mine. Unfortunately, that doesn't work because I don't have 2 scenes but 2 symbols (where we go from one to the other and the function to display the text).
I also need to keep symbols + groups, such as my document in attachment.
Rather than put in attachement my test with the functions of the "dragAndDropPlusResetPlusOffset" doc which does not work, here is the base of the document in attachement.
I put the timelines back to the beginning when we click on the button ("button2", in the symbol "sceen2"), and for the moment the button only manages to return to the first symbol ("sceen1")
How do I can reset the drag and drop, make elements reappear in their original place and return to the initial state of the text block before the drag and drop? Thank you very much by advance for your help :slight_smile: (852.0 KB)

It works with multiple scenes because Hype does a full reset on everything in the scene back to its initial state. If you don't change scenes, then you'll have to do this manually.

My recommendation would be to modify your resettimelines() function to do this. It can either start/go-to-time in other timelines that would move the items back to their initial spot, or if you wanted to use JavaScript fully you could just set the object positions via the hypeDocument.setElementProperty() API.

1 Like

(I just moved over your post and my response to this new topic)

Thank you for your answer :slight_smile: i hope i will find the solution with your recommendations :slight_smile:

Excellent solution for me to reverse the timelines: I placed opacity keys + positions and it's ok to replace the elements at their original position and opacity! Thank you very much!!! :grinning:
but I have one last problem: I tried a "resetText" function to reset the text by clicking on the "restart button" but it does not work. I didn't find the right function
to reset the text before drag and drop (and thus be able to redo a new drag and drop that also works with the text)
Do you know where my errors are in the "erasetext" function? Please !
Here is the progress of my doc in attachment :slight_smile: (843.1 KB)

I'm a little unclear what you are trying to do in the resetText() function but it has many errors.

The first line is:

function sousfonctionresetText(hypeDocument, element, event) {

This puts the entire rest of the contents in a function called sousfonctionresetText, and this function never gets called. This is why your code isn't running. I think you'll just want to delete it and and corresponding close curly bracket } at the end.

var droppedElementName = event.customBehaviorName;

As far as I can tell, resetText() is triggered from a button press on the "restart button" labeled (id=button2) button. This means there's no customBehaviorName field. Therefore the rest of the code that depends on this value will fail, since it does not exist.

If you are just looking to clear out the id=example text field, you could just use code like:

hypeDocument.getElementById("example").innerHTML = "";
1 Like

Thank's a lot for your explanations! I am a graphic designer and not a developer so i am learning little by little. Fortunately, with Hype, you can still do lots of cool things with the software, even if you are not a developer :blush:. But we always want you to do more functions that require JavaScript :blush: In any case, I love this software !!! And I learn more with this forum :slight_smile: :grinning:

1 Like

Thank you for this function :slight_smile:
But if i clic on restart, the inner html stays empty when we want to replay the drag and drop (unless we add another function). On the other hand with your answer "reset timelines", this is fine because i saw that we can add a key "Inner HTML" in timelines.
That's what i did and when we clic on "restart button" it works :slight_smile: I put the document in attachement if anyone else is interested. Thanks a lot (834.4 KB)

1 Like

Great - glad you got it working!