Problem: I would like to find the left and top position of a drag and drop object after the shape has been moved, but the functions .left() and .top() only return the position the shape started at
You can use .translate() function to get the dragged distance (relative to the original position):
var dragObject = prez.object('object name');
var dragDistance = dragObject.translate();
var left = dragObject.left() + dragDistance.translateX;
var top = dragObject.top() + dragDistance.translateY;
I see my problem now - I had the drag source on revert.
However, I do need the revert. Is there a way to make sure that the drag distance is checked first and the revert is done after that.
I know how to do that manually (see Hang’s reply from June 29). I just thought maybe there was a JS way to postpone the revert that AP provides, check whether the drop was correct and revert if it was incorrect.
Thanks, Rolf
P.S.: Just a bit of context.
I’m trying to create a template for basic functionalities of point-and-click adventures for teaching purposes. I am currently working with a basic inventory, which includes drag and drop, e.g. drag the key over the door to unlock the door, etc.
For the envisaged user the template should be as simple as possible, i.e. the inventory object icon is in the masterslide and the drop target is an object on a given slide.
On drag start, I check whether the slide contains the relevant drop target and get its dimensions and size. On drag end, I check whether the new position (left + translateX, etc.) falls within the area covered by the object. This works well, if I do not have the revert and, of course, does not work if the revert box is checked. Hence, the question.
Unfortunately, it’s not possible with the revert option.
In this case, you should not use the revert option that ActivePresenter provides and implement it using your own script.