dojo/dnd/Moveable.js

  • Provides:

    • dojo.dnd.Moveable
  • dojo.dnd.__MoveableArgs

    • type
      Function
    • summary
  • dojo.dnd.__MoveableArgs.handle

    • type
      Node||String
    • summary
      A node (or node's id), which is used as a mouse handle.
      If omitted, the node itself is used as a handle.
  • dojo.dnd.__MoveableArgs.delay

    • type
      Number
    • summary
      delay move by this number of pixels
  • dojo.dnd.__MoveableArgs.skip

    • type
      Boolean
    • summary
      skip move of form elements
  • dojo.dnd.__MoveableArgs.mover

    • type
      Object
    • summary
      a constructor of custom Mover
  • dojo.dnd.Moveable

    • type
      Function
    • parameters:
      • node: (typeof Node)
        a node (or node's id) to be moved
      • params: (typeof dojo.dnd.__MoveableArgs)
        optional parameters
    • source: [view]
        this.node = dojo.byId(node);
        if(!params){ params = {}; }
        this.handle = params.handle ? dojo.byId(params.handle) : null;
        if(!this.handle){ this.handle = this.node; }
        this.delay = params.delay > 0 ? params.delay : 0;
        this.skip = params.skip;
        this.mover = params.mover ? params.mover : dojo.dnd.Mover;
        this.events = [
         dojo.connect(this.handle, "onmousedown", this, "onMouseDown"),
         dojo.connect(this.handle, "ontouchstart", this, "onMouseDown"),
         // cancel text selection and text dragging
         dojo.connect(this.handle, "ondragstart", this, "onSelectStart"),
         dojo.connect(this.handle, "onselectstart", this, "onSelectStart")
        ];
    • summary
      an object, which makes a node moveable
  • dojo.dnd.Moveable.handle

    • summary
  • dojo.dnd.Moveable.delay

    • summary
  • dojo.dnd.Moveable.skip

    • summary
  • dojo.dnd.Moveable.markupFactory

    • type
      Function
    • parameters:
      • params: (typeof )
      • node: (typeof )
    • source: [view]
        return new dojo.dnd.Moveable(node, params);
    • summary
  • dojo.dnd.Moveable.destroy

    • type
      Function
    • source: [view]
        dojo.forEach(this.events, dojo.disconnect);
        this.events = this.node = this.handle = null;
    • summary
      stops watching for possible move, deletes all references, so the object can be garbage-collected
  • dojo.dnd.Moveable.onMouseDown

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse/touch event
    • source: [view]
        if(this.skip && dojo.dnd.isFormElement(e)){ return; }
        if(this.delay){
         this.events.push(
          dojo.connect(this.handle, "onmousemove", this, "onMouseMove"),
          dojo.connect(this.handle, "ontouchmove", this, "onMouseMove"),
          dojo.connect(this.handle, "onmouseup", this, "onMouseUp"),
          dojo.connect(this.handle, "ontouchend", this, "onMouseUp")
         );
         var pos = e.touches ? e.touches[0] : e;
         this._lastX = pos.pageX;
         this._lastY = pos.pageY;
        }else{
         this.onDragDetected(e);
        }
        dojo.stopEvent(e);
    • summary
      event processor for onmousedown/ontouchstart, creates a Mover for the node
  • dojo.dnd.Moveable.onMouseMove

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse/touch event
    • source: [view]
        var pos = e.touches ? e.touches[0] : e;
        if(Math.abs(pos.pageX - this._lastX) > this.delay || Math.abs(pos.pageY - this._lastY) > this.delay){
         this.onMouseUp(e);
         this.onDragDetected(e);
        }
        dojo.stopEvent(e);
    • summary
      event processor for onmousemove/ontouchmove, used only for delayed drags
  • dojo.dnd.Moveable.onMouseUp

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        for(var i = 0; i < 2; ++i){
         dojo.disconnect(this.events.pop());
        }
        dojo.stopEvent(e);
    • summary
      event processor for onmouseup, used only for delayed drags
  • dojo.dnd.Moveable.onSelectStart

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        if(!this.skip || !dojo.dnd.isFormElement(e)){
         dojo.stopEvent(e);
        }
    • summary
      event processor for onselectevent and ondragevent
  • dojo.dnd.Moveable.onDragDetected

    • type
      Function
    • parameters:
      • e: (typeof Event)
    • source: [view]
        new this.mover(this.node, e, this);
    • summary
      called when the drag is detected;
      responsible for creation of the mover
  • dojo.dnd.Moveable.onMoveStart

    • type
      Function
    • parameters:
      • mover: (typeof dojo.dnd.Mover)
    • source: [view]
        dojo.publish("/dnd/move/start", [mover]);
        dojo.addClass(dojo.body(), "dojoMove");
        dojo.addClass(this.node, "dojoMoveItem");
    • summary
      called before every move operation
  • dojo.dnd.Moveable.onMoveStop

    • type
      Function
    • parameters:
      • mover: (typeof dojo.dnd.Mover)
    • source: [view]
        dojo.publish("/dnd/move/stop", [mover]);
        dojo.removeClass(dojo.body(), "dojoMove");
        dojo.removeClass(this.node, "dojoMoveItem");
    • summary
      called after every move operation
  • dojo.dnd.Moveable.onFirstMove

    • type
      Function
    • parameters:
      • mover: (typeof dojo.dnd.Mover)
      • e: (typeof Event)
    • source: [view]
        // summary:
        //  called during the very first move notification;
        //  can be used to initialize coordinates, can be overwritten.

        
        // default implementation does nothing
    • summary
      called during the very first move notification;
      can be used to initialize coordinates, can be overwritten.
      
      default implementation does nothing
  • dojo.dnd.Moveable.onMove

    • type
      Function
    • parameters:
      • mover: (typeof dojo.dnd.Mover)
      • leftTop: (typeof Object)
      • e: (typeof Event)
    • source: [view]
        this.onMoving(mover, leftTop);
        var s = mover.node.style;
        s.left = leftTop.l + "px";
        s.top = leftTop.t + "px";
        this.onMoved(mover, leftTop);
    • summary
      called during every move notification;
      should actually move the node; can be overwritten.
  • dojo.dnd.Moveable.onMoving

    • type
      Function
    • parameters:
      • mover: (typeof dojo.dnd.Mover)
      • leftTop: (typeof Object)
    • source: [view]
        // summary:
        //  called before every incremental move; can be overwritten.

        
        // default implementation does nothing
    • summary
      called before every incremental move; can be overwritten.
      
      default implementation does nothing
  • dojo.dnd.Moveable.onMoved

    • type
      Function
    • parameters:
      • mover: (typeof dojo.dnd.Mover)
      • leftTop: (typeof Object)
    • source: [view]
        // summary:
        //  called after every incremental move; can be overwritten.

        
        // default implementation does nothing
    • summary
      called after every incremental move; can be overwritten.
      
      default implementation does nothing
  • dojo.dnd.Moveable.events

    • summary
  • dojo.dnd.Moveable._lastX

    • summary
  • dojo.dnd.Moveable._lastY

    • summary
  • dojo.dnd.Moveable.node

    • type
      Node
    • summary
      a node (or node's id) to be moved
  • dojo.dnd.Moveable.mover

    • summary
  • dojo.dnd

    • type
      Object
    • summary
  • dojo

    • type
      Object
    • summary