Remove Control Element Position from any element in Javascript


(Andrew) #1

I need to lock a draggable element once it’s in a certain position, but i need to do this with Javascript, rather than a timeline, as there are many elements and certain conditions have to be met.

Everything works fine, but I have been unable to lock the element. So you can still move it after it’s reached the position on the screen.

How can you lock an element ?


(Hans-Gerd Claßen) #2

jquery’s got two methodes for draggables : destroy and disable.
on the other hand you can position a dummyelement above, will work too


(Andrew) #3

I tried disabled, but it did not work, ill try destroy, but not holding much hope. I would have thought i could have removed an action?


(Hans-Gerd Claßen) #4

http://api.jqueryui.com/draggable/#method-destroy

If you’not using jqueryUI then you have to write your own js to control the elements position


(Andrew) #5

I am not using JQuery UI, I am using the control element position on the action to drag it round. I need to know how i can remove that from the action list ? Is that not possible ?


(Hans-Gerd Claßen) #6

no.

use the hyGestureEvents to grab and set the elements position. so you can stop it whenever you want …


(Andrew) #7

I have the gesture = end in place, but how do I make it stop the element from moving again. This is what I am asking. I need the element to stop being draggable once in a position. When its in that place, it goes green, now i need it to stop being draggable. Can you tell me how to achieve this ?


(Greg) #8

Would something simple like having a Box without a background color as the landing area work?

example – box 1 is draggable and box 2 is larger than box 1 – use the “arrange” menu to send box 1 to the rear and bring box 2 forward. Or you could use a javascript for z-index

see attached

lockIt.hype.zip (11.0 KB)


(Andrew) #9

That is a good alternative @gasspence I shall look into that now.