PanelResizer.js
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:2k
源码类别:

JavaScript

开发平台:

JavaScript

  1. /*!  * Ext JS Library 3.1.0  * Copyright(c) 2006-2009 Ext JS, LLC  * licensing@extjs.com  * http://www.extjs.com/license  */ Ext.ux.PanelResizer = Ext.extend(Ext.util.Observable, {
  2.     minHeight: 0,
  3.     maxHeight:10000000,
  4.     constructor: function(config){
  5.         Ext.apply(this, config);
  6.         this.events = {};
  7.         Ext.ux.PanelResizer.superclass.constructor.call(this, config);
  8.     },
  9.     init : function(p){
  10.         this.panel = p;
  11.         if(this.panel.elements.indexOf('footer')==-1){
  12.             p.elements += ',footer';
  13.         }
  14.         p.on('render', this.onRender, this);
  15.     },
  16.     onRender : function(p){
  17.         this.handle = p.footer.createChild({cls:'x-panel-resize'});
  18.         this.tracker = new Ext.dd.DragTracker({
  19.             onStart: this.onDragStart.createDelegate(this),
  20.             onDrag: this.onDrag.createDelegate(this),
  21.             onEnd: this.onDragEnd.createDelegate(this),
  22.             tolerance: 3,
  23.             autoStart: 300
  24.         });
  25.         this.tracker.initEl(this.handle);
  26.         p.on('beforedestroy', this.tracker.destroy, this.tracker);
  27.     },
  28. // private
  29.     onDragStart: function(e){
  30.         this.dragging = true;
  31.         this.startHeight = this.panel.el.getHeight();
  32.         this.fireEvent('dragstart', this, e);
  33.     },
  34. // private
  35.     onDrag: function(e){
  36.         this.panel.setHeight((this.startHeight-this.tracker.getOffset()[1]).constrain(this.minHeight, this.maxHeight));
  37.         this.fireEvent('drag', this, e);
  38.     },
  39. // private
  40.     onDragEnd: function(e){
  41.         this.dragging = false;
  42.         this.fireEvent('dragend', this, e);
  43.     }
  44. });
  45. Ext.preg('panelresizer', Ext.ux.PanelResizer);