Start a new topic
Solved

context.onDrag events

 

 Hi !


I would like to use the context.onDrag events to let the user hide/display html elements.
For that, I need to get the screen coordinates of the event to know in which area the user did it to hode/display the HTML element accordingly. Is it possible to get those with wikitude ?

Moreover, it seems like onDragBegan's event payload isn't "always 0" (as described in the documentation) but is equal to the last onDragEnded's event payload. Hence, when I create a drag event (for exemple x: 0.25, y:0.5), I'll get the same drag event if I then just click somewhere else on the screen (inducing an onDragEnded event with x: 0.25 and y: 0.5 instead of x:0, y: 0).
However, if I do a real drag event (not just a click), I'll get good x and y values...
Is this a bug or am I missreading something ?

I'm using the js API (6.1) with android 7.

thanks for your help,
Vivien

Good morning Vivien,



you are correct about the behaviour of onDragBegan; the passed coordinates should always be 0. Receiving anything other than that seems to me to be a bug in our implementation.


Currently, getting the absolute screen position is not possible using just the Wikitude gesture callbacks. The use-case we had in mind when developing these callbacks was moving augmentations around for which the absolute positions are not required. The only workaround I can think of is subscribing to the regular JavaScript touchstart event and getting the initial position therefrom; then adding that to the offsets received by the Wikitude gesture callbacks.


touchstart



- Daniel



Hi Daniel,

Thank you, that's exactly what I needed !

 

Login or Signup to post a comment