dojox/grid/enhanced/plugins/AutoScroll.js

  • Provides:

    • dojox.grid.enhanced.plugins.AutoScroll
  • Requires:

    • dojox.grid.enhanced._Plugin in common
    • dojox.grid._RowSelector in common
  • dojox.grid.enhanced.plugins.AutoScroll

    • type
      Function
    • chains:
      • dojox.grid.enhanced._Plugin: (prototype)
      • dojox.grid.enhanced._Plugin: (call)
    • summary
      Provides horizontal and vertical auto-scroll for grid.
    • parameters:
      • grid: (typeof )
      • args: (typeof )
    • source: [view]
        this.grid = grid;
        this.readyForAutoScroll = false;
        this._scrolling = false;
        args = dojo.isObject(args) ? args : {};
        if("interval" in args){
         this.autoScrollInterval = args.interval;
        }
        if("margin" in args){
         this.autoScrollMargin = args.margin;
        }
        this._initEvents();
        this._mixinGrid();
  • dojox.grid.enhanced.plugins.AutoScroll.name

    • type
      String
    • summary
      Plugin name
  • dojox.grid.enhanced.plugins.AutoScroll.autoScrollInterval

    • type
      Integer
    • summary
      The time interval (in miliseconds) between 2 scrolling.
  • dojox.grid.enhanced.plugins.AutoScroll.autoScrollMargin

    • type
      Integer
    • summary
      The width (in pixel) of the margin area where autoscroll can be triggered.
  • dojox.grid.enhanced.plugins.AutoScroll._initEvents

    • type
      Function
    • source: [view]
        var g = this.grid;
        this.connect(g, "onCellMouseDown", function(){
         this.readyForAutoScroll = true;
        });
        this.connect(g, "onHeaderCellMouseDown", function(){
         this.readyForAutoScroll = true;
        });
        this.connect(g, "onRowSelectorMouseDown", function(){
         this.readyForAutoScroll = true;
        });
        this.connect(dojo.doc, "onmouseup", function(evt){
         this._manageAutoScroll(true);
         this.readyForAutoScroll = false;
        });
        this.connect(dojo.doc, "onmousemove", function(evt){
         if(this.readyForAutoScroll){
          this._event = evt;
          var gridPos = dojo.position(g.domNode),
           hh = g._getHeaderHeight(),
           margin = this.autoScrollMargin,
           ey = evt.clientY, ex = evt.clientX,
           gy = gridPos.y, gx = gridPos.x,
           gh = gridPos.h, gw = gridPos.w;
          if(ex >= gx && ex <= gx + gw){
           if(ey >= gy + hh && ey < gy + hh + margin){
            this._manageAutoScroll(false, true, false);
            return;
           }else if(ey > gy + gh - margin && ey <= gy + gh){
            this._manageAutoScroll(false, true, true);
            return;
           }else if(ey >= gy && ey <= gy + gh){
            var withinSomeview = dojo.some(g.views.views, function(view, i){
             if(view instanceof dojox.grid._RowSelector){
              return false;
             }
             var viewPos = dojo.position(view.domNode);
             if(ex < viewPos.x + margin && ex >= viewPos.x){
              this._manageAutoScroll(false, false, false, view);
              return true;
             }else if(ex > viewPos.x + viewPos.w - margin && ex < viewPos.x + viewPos.w){
              this._manageAutoScroll(false, false, true, view);
              return true;
             }
             return false;
            }, this);
            if(withinSomeview){
             return;
            }
           }
          }
          //stop autoscroll.
          this._manageAutoScroll(true);
         }
        });
    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._mixinGrid

    • type
      Function
    • source: [view]
        var g = this.grid;
        g.onStartAutoScroll = function(/*isVertical, isForward*/){};
        g.onEndAutoScroll = function(/*isVertical, isForward, view, scrollToRowIndex, event*/){};
    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._fireEvent

    • type
      Function
    • parameters:
      • eventName: (typeof )
      • args: (typeof )
    • source: [view]
        var g = this.grid;
        switch(eventName){
         case "start":
          g.onStartAutoScroll.apply(g, args);
          break;
         case "end":
          g.onEndAutoScroll.apply(g, args);
          break;
        }
    • chains:
      • g.onStartAutoScroll: (call)
      • g.onEndAutoScroll: (call)
    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._manageAutoScroll

    • type
      Function
    • parameters:
      • toStop: (typeof )
      • isVertical: (typeof )
      • isForward: (typeof )
      • view: (typeof )
    • source: [view]
        if(toStop){
         this._scrolling = false;
         clearInterval(this._handler);
        }else if(!this._scrolling){
         this._scrolling = true;
         this._fireEvent("start", [isVertical, isForward, view]);
         this._autoScroll(isVertical, isForward, view);
         this._handler = setInterval(dojo.hitch(this, "_autoScroll", isVertical, isForward, view), this.autoScrollInterval);
        }
    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._autoScroll

    • type
      Function
    • parameters:
      • isVertical: (typeof )
      • isForward: (typeof )
      • view: (typeof )
    • source: [view]
        var g = this.grid,
         target = null;
        if(isVertical){
         var targetRow = g.scroller.firstVisibleRow + (isForward ? 1 : -1);
         if(targetRow >= 0 && targetRow < g.rowCount){
          g.scrollToRow(targetRow);
          target = targetRow;
         }
        }else{
         target = this._scrollColumn(isForward, view);
        }
        if(target !== null){
         this._fireEvent("end", [isVertical, isForward, view, target, this._event]);
        }
    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._scrollColumn

    • type
      Function
    • parameters:
      • isForward: (typeof )
      • view: (typeof )
    • source: [view]
        var node = view.scrollboxNode,
         target = null;
        if(node.clientWidth < node.scrollWidth){
         var cells = dojo.filter(this.grid.layout.cells, function(cell){
          return !cell.hidden;
         });
         var viewPos = dojo.position(view.domNode);
         var limit, edge, headerPos, i;
         if(isForward){
          limit = node.clientWidth;
          for(i = 0; i < cells.length; ++i){
           headerPos = dojo.position(cells[i].getHeaderNode());
           edge = headerPos.x - viewPos.x + headerPos.w;
           if(edge > limit){
            target = cells[i].index;
            node.scrollLeft += edge - limit + 10;
            break;
           }
          }
         }else{
          limit = 0;
          for(i = cells.length - 1; i >= 0; --i){
           headerPos = dojo.position(cells[i].getHeaderNode());
           edge = headerPos.x - viewPos.x;
           if(edge < limit){
            target = cells[i].index;
            node.scrollLeft += edge - limit - 10;
            break;
           }
          }
         }
        }
        return target;
    • summary
  • dojox.grid.enhanced.plugins.AutoScroll.readyForAutoScroll

    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._event

    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._scrolling

    • summary
  • dojox.grid.enhanced.plugins.AutoScroll._handler

    • summary
  • dojox.grid.enhanced.plugins.AutoScroll.grid

    • summary
  • dojox.grid.enhanced.plugins

    • type
      Object
    • summary
  • dojox.grid.enhanced

    • type
      Object
    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary