Capture Left and Top properties before Drag event

Hello everyone! I have 6 elements in a scene. Each has a Drag action (Control Element Position) and Run JavaScript action (function abc) associated with it.

In this JS function 'abc’I am using hypeDocument.getElementProperty(element, ‘left’) and hypeDocument.getElementProperty(element, ‘top’) to get an element’s x and y values - but these x and y are after the Drag event has started because this JS function ‘abc’ starts with the Drag event.

How can I know the original x and y (left and top) values of each element before the Drag event and be able to use these values in this JS function, abc? Thanks for your help, as always.

@aStoryTeller

Try the following in your JS code:

if(event['hypeGesturePhase'] == hypeDocument.kHypeGesturePhaseStart) {
	var x = hypeDocument.getElementProperty(element, 'left');
	var y = hypeDocument.getElementProperty(element, 'top');
	}; 

console.log(x, y);

Note the use of “.kHypeGesturePhaseStart” which records the object’s location at the start of the drag.

See the Documentation for more about the “On Drag” handler & ‘hypeGesturePhase’ (also do a Forum search for more examples).

3 Likes

Jim, thank you so much. Worked like a charm:) I didn’t think I could use that function since I already started the drag event, but that’s what it is intended for - I get it now:) Thanks again for your help.

1 Like