dojox/drawing/ui/dom/Pan.js

  • Provides:

    • dojox.drawing.ui.dom.Pan
  • Requires:

    • dojox.drawing.plugins._Plugin in common
  • dojox.drawing.ui.dom.Pan.setup

    • type
      Object
    • summary
  • dojox.drawing.ui.dom.Pan.setup.name

    • summary
  • dojox.drawing.ui.dom.Pan.setup.tooltip

    • summary
  • dojox.drawing.ui.dom.Pan.setup.iconClass

    • summary
  • log

    • type
      Function
    • source: [view]
      dojo.provide("dojox.drawing.ui.dom.Pan");
      dojo.require("dojox.drawing.plugins._Plugin");
      dojo.deprecated("dojox.drawing.ui.dom.Pan", "It may not even make it to the 1.4 release.", 1.4);


      dojox.drawing.ui.dom.Pan = dojox.drawing.util.oo.declare(
       // NOTE:
       //   dojox.drawing.ui.dom.Pan is DEPRECATED.
       //   This was a temporary DOM solution. Use the non-dom
       //   tools for Toobar and Plugins.
       //
       // summary:
       //  A plugin that allows for a scrolling canvas. An action
       //  tool is added to the toolbar that allows for panning. Holding
       //  the space bar is a shortcut to that action. The canvas will
       //  only pan and scroll if there are objects out of the viewable
       //  area.
       // example:
       //  | 

       //  |  
      Line

       //  |  
      Pan

       //  | 

       //
       dojox.drawing.plugins._Plugin,
       function(options){

        
        this.domNode = options.node;
        var _scrollTimeout;
        dojo.connect(this.domNode, "click", this, "onSetPan");
        dojo.connect(this.keys, "onKeyUp", this, "onKeyUp");
        dojo.connect(this.keys, "onKeyDown", this, "onKeyDown");
        dojo.connect(this.anchors, "onAnchorUp", this, "checkBounds");
        dojo.connect(this.stencils, "register", this, "checkBounds");
        dojo.connect(this.canvas, "resize", this, "checkBounds");
        dojo.connect(this.canvas, "setZoom", this, "checkBounds");
        dojo.connect(this.canvas, "onScroll", this, function(){
         if(this._blockScroll){
          this._blockScroll = false;
          return;
         }
         _scrollTimeout && clearTimeout(_scrollTimeout);
         _scrollTimeout = setTimeout(dojo.hitch(this, "checkBounds"), 200);
        });
        this._mouseHandle = this.mouse.register(this);
        // This HAS to be called after setting initial objects or things get screwy.
        //this.checkBounds();
       },{
        selected:false,
        type:"dojox.drawing.ui.dom.Pan",

        
        onKeyUp: function(evt){
         if(evt.keyCode == 32){
          this.onSetPan(false);
         }
        },

        
        onKeyDown: function(evt){
         if(evt.keyCode == 32){
          this.onSetPan(true);
         }
        },

        
        onSetPan: function(/*Boolean | Event*/ bool){
         if(bool === true || bool === false){
          this.selected = !bool;
         }
         if(this.selected){
          this.selected = false;
          dojo.removeClass(this.domNode, "selected");
         }else{
          this.selected = true;
          dojo.addClass(this.domNode, "selected");
         }
         this.mouse.setEventMode(this.selected ? "pan" : "");
        },

        
        onPanDrag: function(obj){
         var x = obj.x - obj.last.x;
         var y = obj.y - obj.last.y;
         this.canvas.domNode.parentNode.scrollTop -= obj.move.y;
         this.canvas.domNode.parentNode.scrollLeft -= obj.move.x;
         this.canvas.onScroll();
        },

        
        onStencilUp: function(obj){
         // this gets called even on click-off because of the
         // issues with TextBlock deselection
         this.checkBounds();
        },
        onStencilDrag: function(obj){
         // this gets called even on click-off because of the
         // issues with TextBlock deselection
         //this.checkBounds();
        },

        
        checkBounds: function(){

         
         //watch("CHECK BOUNDS DISABLED", true); return;

         

         
         // summary:
         //  Scans all items on the canvas and checks if they are out of
         //   bounds. If so, a scroll bar (in Canvas) is shown. If the position
         //   is left or top, the canvas is scrolled all items are relocated
         //   the distance of the scroll. Ideally, it should look as if the
         //   items do not move.

         
         // logging stuff here so it can be turned on and off. This method is
         // very high maintenance.
         var log = function(){
          ///console.log.apply(console, arguments);
    • summary
  • warn

    • type
      Function
    • source: [view]
      dojo.provide("dojox.drawing.ui.dom.Pan");
      dojo.require("dojox.drawing.plugins._Plugin");
      dojo.deprecated("dojox.drawing.ui.dom.Pan", "It may not even make it to the 1.4 release.", 1.4);


      dojox.drawing.ui.dom.Pan = dojox.drawing.util.oo.declare(
       // NOTE:
       //   dojox.drawing.ui.dom.Pan is DEPRECATED.
       //   This was a temporary DOM solution. Use the non-dom
       //   tools for Toobar and Plugins.
       //
       // summary:
       //  A plugin that allows for a scrolling canvas. An action
       //  tool is added to the toolbar that allows for panning. Holding
       //  the space bar is a shortcut to that action. The canvas will
       //  only pan and scroll if there are objects out of the viewable
       //  area.
       // example:
       //  | 

       //  |  
      Line

       //  |  
      Pan

       //  | 

       //
       dojox.drawing.plugins._Plugin,
       function(options){

        
        this.domNode = options.node;
        var _scrollTimeout;
        dojo.connect(this.domNode, "click", this, "onSetPan");
        dojo.connect(this.keys, "onKeyUp", this, "onKeyUp");
        dojo.connect(this.keys, "onKeyDown", this, "onKeyDown");
        dojo.connect(this.anchors, "onAnchorUp", this, "checkBounds");
        dojo.connect(this.stencils, "register", this, "checkBounds");
        dojo.connect(this.canvas, "resize", this, "checkBounds");
        dojo.connect(this.canvas, "setZoom", this, "checkBounds");
        dojo.connect(this.canvas, "onScroll", this, function(){
         if(this._blockScroll){
          this._blockScroll = false;
          return;
         }
         _scrollTimeout && clearTimeout(_scrollTimeout);
         _scrollTimeout = setTimeout(dojo.hitch(this, "checkBounds"), 200);
        });
        this._mouseHandle = this.mouse.register(this);
        // This HAS to be called after setting initial objects or things get screwy.
        //this.checkBounds();
       },{
        selected:false,
        type:"dojox.drawing.ui.dom.Pan",

        
        onKeyUp: function(evt){
         if(evt.keyCode == 32){
          this.onSetPan(false);
         }
        },

        
        onKeyDown: function(evt){
         if(evt.keyCode == 32){
          this.onSetPan(true);
         }
        },

        
        onSetPan: function(/*Boolean | Event*/ bool){
         if(bool === true || bool === false){
          this.selected = !bool;
         }
         if(this.selected){
          this.selected = false;
          dojo.removeClass(this.domNode, "selected");
         }else{
          this.selected = true;
          dojo.addClass(this.domNode, "selected");
         }
         this.mouse.setEventMode(this.selected ? "pan" : "");
        },

        
        onPanDrag: function(obj){
         var x = obj.x - obj.last.x;
         var y = obj.y - obj.last.y;
         this.canvas.domNode.parentNode.scrollTop -= obj.move.y;
         this.canvas.domNode.parentNode.scrollLeft -= obj.move.x;
         this.canvas.onScroll();
        },

        
        onStencilUp: function(obj){
         // this gets called even on click-off because of the
         // issues with TextBlock deselection
         this.checkBounds();
        },
        onStencilDrag: function(obj){
         // this gets called even on click-off because of the
         // issues with TextBlock deselection
         //this.checkBounds();
        },

        
        checkBounds: function(){

         
         //watch("CHECK BOUNDS DISABLED", true); return;

         

         
         // summary:
         //  Scans all items on the canvas and checks if they are out of
         //   bounds. If so, a scroll bar (in Canvas) is shown. If the position
         //   is left or top, the canvas is scrolled all items are relocated
         //   the distance of the scroll. Ideally, it should look as if the
         //   items do not move.

         
         // logging stuff here so it can be turned on and off. This method is
         // very high maintenance.
         var log = function(){
          ///console.log.apply(console, arguments);
         };
         var warn = function(){
          //console.warn.apply(console, arguments);
    • summary
  • dojox.drawing.ui.dom.Pan

    • summary
  • this.domNode

    • summary
  • this._blockScroll

    • summary
  • _scrollTimeout

    • summary
  • this._mouseHandle

    • summary
  • this.selected

    • summary
  • x

    • summary
  • y

    • summary
  • t

    • summary
  • sx

    • summary
  • mx

    • summary
  • sc

    • summary
  • scY

    • summary
  • scX

    • summary
  • ch

    • summary
  • cw

    • summary
  • z

    • summary
  • pch

    • summary
  • pcw

    • summary
  • o

    • summary
  • r

    • summary
  • b

    • summary
  • l

    • summary
  • xscroll

    • summary
  • sy

    • summary
  • dojox.drawing.ui.dom

    • type
      Object
    • summary
  • dojox.drawing.ui

    • type
      Object
    • summary
  • dojox.drawing

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary