dojox/gfx/Moveable.js

  • Provides:

    • dojox.gfx.Moveable
  • Requires:

    • dojox.gfx.Mover in common
  • dojox.gfx.Moveable

    • type
      Function
    • parameters:
      • shape: (typeof dojox.gfx.Shape)
        a shape object to be moved
      • params: (typeof Object)
        an optional object with additional parameters;
        following parameters are recognized:
    • source: [view]
        this.shape = shape;
        this.delay = (params && params.delay > 0) ? params.delay : 0;
        this.mover = (params && params.mover) ? params.mover : dojox.gfx.Mover;
        this.events = [
         this.shape.connect("onmousedown", this, "onMouseDown")
         // cancel text selection and text dragging
         //, dojo.connect(this.handle, "ondragstart", dojo, "stopEvent")
         //, dojo.connect(this.handle, "onselectstart", dojo, "stopEvent")
        ];
    • summary
      an object, which makes a shape moveable
  • dojox.gfx.Moveable.destroy

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

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        if(this.delay){
         this.events.push(
          this.shape.connect("onmousemove", this, "onMouseMove"),
          this.shape.connect("onmouseup", this, "onMouseUp"));
         this._lastX = e.clientX;
         this._lastY = e.clientY;
        }else{
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
    • summary
      event processor for onmousedown, creates a Mover for the shape
  • dojox.gfx.Moveable.onMouseMove

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        if(Math.abs(e.clientX - this._lastX) > this.delay || Math.abs(e.clientY - this._lastY) > this.delay){
         this.onMouseUp(e);
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
    • summary
      event processor for onmousemove, used only for delayed drags
  • dojox.gfx.Moveable.onMouseUp

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        this.shape.disconnect(this.events.pop());
        this.shape.disconnect(this.events.pop());
    • summary
      event processor for onmouseup, used only for delayed delayed drags
  • dojox.gfx.Moveable.onMoveStart

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

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

    • type
      Function
    • parameters:
      • mover: (typeof dojox.gfx.Mover)
    • source: [view]
      dojo.provide("dojox.gfx.Moveable");


      dojo.require("dojox.gfx.Mover");


      dojo.declare("dojox.gfx.Moveable", null, {
       constructor: function(shape, params){
        // summary: an object, which makes a shape moveable
        // shape: dojox.gfx.Shape: a shape object to be moved
        // params: Object: an optional object with additional parameters;
        // following parameters are recognized:
        //  delay: Number: delay move by this number of pixels
        //  mover: Object: a constructor of custom Mover
        this.shape = shape;
        this.delay = (params && params.delay > 0) ? params.delay : 0;
        this.mover = (params && params.mover) ? params.mover : dojox.gfx.Mover;
        this.events = [
         this.shape.connect("onmousedown", this, "onMouseDown")
         // cancel text selection and text dragging
         //, dojo.connect(this.handle, "ondragstart", dojo, "stopEvent")
         //, dojo.connect(this.handle, "onselectstart", dojo, "stopEvent")
        ];
       },


       // methods
       destroy: function(){
        // summary: stops watching for possible move, deletes all references, so the object can be garbage-collected
        dojo.forEach(this.events, this.shape.disconnect, this.shape);
        this.events = this.shape = null;
       },


       // mouse event processors
       onMouseDown: function(e){
        // summary: event processor for onmousedown, creates a Mover for the shape
        // e: Event: mouse event
        if(this.delay){
         this.events.push(
          this.shape.connect("onmousemove", this, "onMouseMove"),
          this.shape.connect("onmouseup", this, "onMouseUp"));
         this._lastX = e.clientX;
         this._lastY = e.clientY;
        }else{
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
       },
       onMouseMove: function(e){
        // summary: event processor for onmousemove, used only for delayed drags
        // e: Event: mouse event
        if(Math.abs(e.clientX - this._lastX) > this.delay || Math.abs(e.clientY - this._lastY) > this.delay){
         this.onMouseUp(e);
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
       },
       onMouseUp: function(e){
        // summary: event processor for onmouseup, used only for delayed delayed drags
        // e: Event: mouse event
        this.shape.disconnect(this.events.pop());
        this.shape.disconnect(this.events.pop());
       },


       // local events
       onMoveStart: function(/* dojox.gfx.Mover */ mover){
        // summary: called before every move operation
        dojo.publish("/gfx/move/start", [mover]);
        dojo.addClass(dojo.body(), "dojoMove");
       },
       onMoveStop: function(/* dojox.gfx.Mover */ mover){
        // summary: called after every move operation
        dojo.publish("/gfx/move/stop", [mover]);
        dojo.removeClass(dojo.body(), "dojoMove");
       },
       onFirstMove: function(/* dojox.gfx.Mover */ mover){
        // summary: called during the very first move notification,
        // can be used to initialize coordinates, can be overwritten.


        // default implementation does nothing
    • summary
  • dojox.gfx.Moveable.onMove

    • type
      Function
    • parameters:
      • mover: (typeof dojox.gfx.Mover)
      • shift: (typeof Object)
    • source: [view]
        this.onMoving(mover, shift);
        this.shape.applyLeftTransform(shift);
        this.onMoved(mover, shift);
    • summary
      called during every move notification,
      should actually move the node, can be overwritten.
  • dojox.gfx.Moveable.onMoving

    • type
      Function
    • parameters:
      • mover: (typeof dojox.gfx.Mover)
      • shift: (typeof Object)
    • source: [view]
      dojo.provide("dojox.gfx.Moveable");


      dojo.require("dojox.gfx.Mover");


      dojo.declare("dojox.gfx.Moveable", null, {
       constructor: function(shape, params){
        // summary: an object, which makes a shape moveable
        // shape: dojox.gfx.Shape: a shape object to be moved
        // params: Object: an optional object with additional parameters;
        // following parameters are recognized:
        //  delay: Number: delay move by this number of pixels
        //  mover: Object: a constructor of custom Mover
        this.shape = shape;
        this.delay = (params && params.delay > 0) ? params.delay : 0;
        this.mover = (params && params.mover) ? params.mover : dojox.gfx.Mover;
        this.events = [
         this.shape.connect("onmousedown", this, "onMouseDown")
         // cancel text selection and text dragging
         //, dojo.connect(this.handle, "ondragstart", dojo, "stopEvent")
         //, dojo.connect(this.handle, "onselectstart", dojo, "stopEvent")
        ];
       },


       // methods
       destroy: function(){
        // summary: stops watching for possible move, deletes all references, so the object can be garbage-collected
        dojo.forEach(this.events, this.shape.disconnect, this.shape);
        this.events = this.shape = null;
       },


       // mouse event processors
       onMouseDown: function(e){
        // summary: event processor for onmousedown, creates a Mover for the shape
        // e: Event: mouse event
        if(this.delay){
         this.events.push(
          this.shape.connect("onmousemove", this, "onMouseMove"),
          this.shape.connect("onmouseup", this, "onMouseUp"));
         this._lastX = e.clientX;
         this._lastY = e.clientY;
        }else{
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
       },
       onMouseMove: function(e){
        // summary: event processor for onmousemove, used only for delayed drags
        // e: Event: mouse event
        if(Math.abs(e.clientX - this._lastX) > this.delay || Math.abs(e.clientY - this._lastY) > this.delay){
         this.onMouseUp(e);
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
       },
       onMouseUp: function(e){
        // summary: event processor for onmouseup, used only for delayed delayed drags
        // e: Event: mouse event
        this.shape.disconnect(this.events.pop());
        this.shape.disconnect(this.events.pop());
       },


       // local events
       onMoveStart: function(/* dojox.gfx.Mover */ mover){
        // summary: called before every move operation
        dojo.publish("/gfx/move/start", [mover]);
        dojo.addClass(dojo.body(), "dojoMove");
       },
       onMoveStop: function(/* dojox.gfx.Mover */ mover){
        // summary: called after every move operation
        dojo.publish("/gfx/move/stop", [mover]);
        dojo.removeClass(dojo.body(), "dojoMove");
       },
       onFirstMove: function(/* dojox.gfx.Mover */ mover){
        // summary: called during the very first move notification,
        // can be used to initialize coordinates, can be overwritten.


        // default implementation does nothing
       },
       onMove: function(/* dojox.gfx.Mover */ mover, /* Object */ shift){
        // summary: called during every move notification,
        // should actually move the node, can be overwritten.
        this.onMoving(mover, shift);
        this.shape.applyLeftTransform(shift);
        this.onMoved(mover, shift);
       },
       onMoving: function(/* dojox.gfx.Mover */ mover, /* Object */ shift){
        // summary: called before every incremental move,
        // can be overwritten.


        // default implementation does nothing
    • summary
  • dojox.gfx.Moveable.onMoved

    • type
      Function
    • parameters:
      • mover: (typeof dojox.gfx.Mover)
      • shift: (typeof Object)
    • source: [view]
      dojo.provide("dojox.gfx.Moveable");


      dojo.require("dojox.gfx.Mover");


      dojo.declare("dojox.gfx.Moveable", null, {
       constructor: function(shape, params){
        // summary: an object, which makes a shape moveable
        // shape: dojox.gfx.Shape: a shape object to be moved
        // params: Object: an optional object with additional parameters;
        // following parameters are recognized:
        //  delay: Number: delay move by this number of pixels
        //  mover: Object: a constructor of custom Mover
        this.shape = shape;
        this.delay = (params && params.delay > 0) ? params.delay : 0;
        this.mover = (params && params.mover) ? params.mover : dojox.gfx.Mover;
        this.events = [
         this.shape.connect("onmousedown", this, "onMouseDown")
         // cancel text selection and text dragging
         //, dojo.connect(this.handle, "ondragstart", dojo, "stopEvent")
         //, dojo.connect(this.handle, "onselectstart", dojo, "stopEvent")
        ];
       },


       // methods
       destroy: function(){
        // summary: stops watching for possible move, deletes all references, so the object can be garbage-collected
        dojo.forEach(this.events, this.shape.disconnect, this.shape);
        this.events = this.shape = null;
       },


       // mouse event processors
       onMouseDown: function(e){
        // summary: event processor for onmousedown, creates a Mover for the shape
        // e: Event: mouse event
        if(this.delay){
         this.events.push(
          this.shape.connect("onmousemove", this, "onMouseMove"),
          this.shape.connect("onmouseup", this, "onMouseUp"));
         this._lastX = e.clientX;
         this._lastY = e.clientY;
        }else{
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
       },
       onMouseMove: function(e){
        // summary: event processor for onmousemove, used only for delayed drags
        // e: Event: mouse event
        if(Math.abs(e.clientX - this._lastX) > this.delay || Math.abs(e.clientY - this._lastY) > this.delay){
         this.onMouseUp(e);
         new this.mover(this.shape, e, this);
        }
        dojo.stopEvent(e);
       },
       onMouseUp: function(e){
        // summary: event processor for onmouseup, used only for delayed delayed drags
        // e: Event: mouse event
        this.shape.disconnect(this.events.pop());
        this.shape.disconnect(this.events.pop());
       },


       // local events
       onMoveStart: function(/* dojox.gfx.Mover */ mover){
        // summary: called before every move operation
        dojo.publish("/gfx/move/start", [mover]);
        dojo.addClass(dojo.body(), "dojoMove");
       },
       onMoveStop: function(/* dojox.gfx.Mover */ mover){
        // summary: called after every move operation
        dojo.publish("/gfx/move/stop", [mover]);
        dojo.removeClass(dojo.body(), "dojoMove");
       },
       onFirstMove: function(/* dojox.gfx.Mover */ mover){
        // summary: called during the very first move notification,
        // can be used to initialize coordinates, can be overwritten.


        // default implementation does nothing
       },
       onMove: function(/* dojox.gfx.Mover */ mover, /* Object */ shift){
        // summary: called during every move notification,
        // should actually move the node, can be overwritten.
        this.onMoving(mover, shift);
        this.shape.applyLeftTransform(shift);
        this.onMoved(mover, shift);
       },
       onMoving: function(/* dojox.gfx.Mover */ mover, /* Object */ shift){
        // summary: called before every incremental move,
        // can be overwritten.


        // default implementation does nothing
       },
       onMoved: function(/* dojox.gfx.Mover */ mover, /* Object */ shift){
        // summary: called after every incremental move,
        // can be overwritten.


        // default implementation does nothing
    • summary
  • dojox.gfx.Moveable.events

    • summary
  • dojox.gfx.Moveable._lastX

    • summary
  • dojox.gfx.Moveable._lastY

    • summary
  • dojox.gfx.Moveable.shape

    • type
      dojox.gfx.Shape
    • summary
      a shape object to be moved
  • dojox.gfx.Moveable.delay

    • type
      Number
    • summary
      delay move by this number of pixels
  • dojox.gfx.Moveable.mover

    • type
      Object
    • summary
      a constructor of custom Mover
  • dojox.gfx

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary