0

I am working on a rotatable plugin for gwtquery. The idea is to create a seating chart app for teacher. Any how I can now get an element to rotate if as long as its not draggable.

What the plugin does is appends a child and makes the child draggable and uses the x and y from screen to get atan2 radians from a center point ... the parent's center point. If the parent is constantly moving then the ceterpoint isn't fixed and thus no rotation.

I've tried the following to trying and disable the parent but to no avail

 private final DragFunction start = new DragFunction(){

    @Override
    public void f(DragContext context) {
        //check to see if parent is draggable
        DraggableOptions disable = new DraggableOptions();
        disable.setDisabled(true);
        $(context.getDraggable()).css($$("background-color:Magenta"));
        $(context.getDraggable()).parent().css($$("border: 3px solid Magenta"));
        //The parent's border indeed turned magenta
        //but the draggable parent was not disable :{
        $(context.getDraggable()).parent().as(Draggable).options(disable);
    $(document).on("mousemove.rotatable", new Function(){
        @Override
        public boolean f(Event e){

            e.stopPropagation();
            e.preventDefault();

            mouseCoords = new Point( e.getScreenX(), e.getScreenY());
            angle = radToDeg(getAngle(mouseCoords, centerCoords));
            rotate(angle);
            rotating = true;
            return true;
        }
    }); 
    };// end start
};

Any help at all is greatly appreciated

1 Answers1

0

The question is "why is the parent draggable if you don't need that ?"

If you realy need that the parent is draggable, the best in your case is to add a dragFunction to the parent that are checking the value of a boolean. If this boolean is false, throws a StopDragException to stop the drag of the parent. Set this boolean to false in your start function above. And set back this boolean to true when the child stops to drag.

jdramaix
  • 1,104
  • 6
  • 9
  • The parent needs to be draggable so it can move to a designated area in a constrained space. I also need to be able to rotate the parent. The case is that the two shouldn't happen at the same time. I'll check out this solution thanks. – Lee ViDemantay Aug 26 '14 at 12:44
  • This solution won't work. I have no control over the parent being draggable or not, but if it is draggable I want to be able to disable the dragging as the child is being dragged. The child is just my rotate handle. I'm guessing a possible solution is to move the handle outside of the parent container??? Still there should be away to stop the parent from dragging. – Lee ViDemantay Aug 26 '14 at 14:37
  • if the parent is draggable you can start to listen on the dragEvent of the parent when the child is dragging and throws a StopDragException. I will edit my answer – jdramaix Aug 26 '14 at 20:55