Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / docs / source / ScrollManager.html
index 09c80a4..a3bd368 100644 (file)
 <html>
 <head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
   <title>The source code</title>
     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
 </head>
 <body  onload="prettyPrint();">
     <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.3.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
-<div id="cls-Ext.dd.ScrollManager"></div>/**\r
- * @class Ext.dd.ScrollManager\r
- * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>\r
- * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,\r
- * but you can also override most of the configs per scroll container by adding a \r
- * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},\r
- * {@link #vthresh}, {@link #increment} and {@link #frequency}.  Example usage:\r
- * <pre><code>\r
-var el = Ext.get('scroll-ct');\r
-el.ddScrollConfig = {\r
-    vthresh: 50,\r
-    hthresh: -1,\r
-    frequency: 100,\r
-    increment: 200\r
-};\r
-Ext.dd.ScrollManager.register(el);\r
-</code></pre>\r
- * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>\r
- * @singleton\r
- */\r
-Ext.dd.ScrollManager = function(){\r
-    var ddm = Ext.dd.DragDropMgr;\r
-    var els = {};\r
-    var dragEl = null;\r
-    var proc = {};\r
-    \r
-    var onStop = function(e){\r
-        dragEl = null;\r
-        clearProc();\r
-    };\r
-    \r
-    var triggerRefresh = function(){\r
-        if(ddm.dragCurrent){\r
-             ddm.refreshCache(ddm.dragCurrent.groups);\r
-        }\r
-    };\r
-    \r
-    var doScroll = function(){\r
-        if(ddm.dragCurrent){\r
-            var dds = Ext.dd.ScrollManager;\r
-            var inc = proc.el.ddScrollConfig ?\r
-                      proc.el.ddScrollConfig.increment : dds.increment;\r
-            if(!dds.animate){\r
-                if(proc.el.scroll(proc.dir, inc)){\r
-                    triggerRefresh();\r
-                }\r
-            }else{\r
-                proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);\r
-            }\r
-        }\r
-    };\r
-    \r
-    var clearProc = function(){\r
-        if(proc.id){\r
-            clearInterval(proc.id);\r
-        }\r
-        proc.id = 0;\r
-        proc.el = null;\r
-        proc.dir = "";\r
-    };\r
-    \r
-    var startProc = function(el, dir){\r
-        clearProc();\r
-        proc.el = el;\r
-        proc.dir = dir;\r
-        var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ? \r
-                el.ddScrollConfig.frequency : Ext.dd.ScrollManager.frequency;\r
-        proc.id = setInterval(doScroll, freq);\r
-    };\r
-    \r
-    var onFire = function(e, isDrop){\r
-        if(isDrop || !ddm.dragCurrent){ return; }\r
-        var dds = Ext.dd.ScrollManager;\r
-        if(!dragEl || dragEl != ddm.dragCurrent){\r
-            dragEl = ddm.dragCurrent;\r
-            // refresh regions on drag start\r
-            dds.refreshCache();\r
-        }\r
-        \r
-        var xy = Ext.lib.Event.getXY(e);\r
-        var pt = new Ext.lib.Point(xy[0], xy[1]);\r
-        for(var id in els){\r
-            var el = els[id], r = el._region;\r
-            var c = el.ddScrollConfig ? el.ddScrollConfig : dds;\r
-            if(r && r.contains(pt) && el.isScrollable()){\r
-                if(r.bottom - pt.y <= c.vthresh){\r
-                    if(proc.el != el){\r
-                        startProc(el, "down");\r
-                    }\r
-                    return;\r
-                }else if(r.right - pt.x <= c.hthresh){\r
-                    if(proc.el != el){\r
-                        startProc(el, "left");\r
-                    }\r
-                    return;\r
-                }else if(pt.y - r.top <= c.vthresh){\r
-                    if(proc.el != el){\r
-                        startProc(el, "up");\r
-                    }\r
-                    return;\r
-                }else if(pt.x - r.left <= c.hthresh){\r
-                    if(proc.el != el){\r
-                        startProc(el, "right");\r
-                    }\r
-                    return;\r
-                }\r
-            }\r
-        }\r
-        clearProc();\r
-    };\r
-    \r
-    ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);\r
-    ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);\r
-    \r
-    return {\r
-        <div id="method-Ext.dd.ScrollManager-register"></div>/**\r
-         * Registers new overflow element(s) to auto scroll\r
-         * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either\r
-         */\r
-        register : function(el){\r
-            if(Ext.isArray(el)){\r
-                for(var i = 0, len = el.length; i < len; i++) {\r
-                       this.register(el[i]);\r
-                }\r
-            }else{\r
-                el = Ext.get(el);\r
-                els[el.id] = el;\r
-            }\r
-        },\r
-        \r
-        <div id="method-Ext.dd.ScrollManager-unregister"></div>/**\r
-         * Unregisters overflow element(s) so they are no longer scrolled\r
-         * @param {Mixed/Array} el The id of or the element to be removed or an array of either\r
-         */\r
-        unregister : function(el){\r
-            if(Ext.isArray(el)){\r
-                for(var i = 0, len = el.length; i < len; i++) {\r
-                       this.unregister(el[i]);\r
-                }\r
-            }else{\r
-                el = Ext.get(el);\r
-                delete els[el.id];\r
-            }\r
-        },\r
-        \r
-        <div id="prop-Ext.dd.ScrollManager-vthresh"></div>/**\r
-         * The number of pixels from the top or bottom edge of a container the pointer needs to be to\r
-         * trigger scrolling (defaults to 25)\r
-         * @type Number\r
-         */\r
-        vthresh : 25,\r
-        <div id="prop-Ext.dd.ScrollManager-hthresh"></div>/**\r
-         * The number of pixels from the right or left edge of a container the pointer needs to be to\r
-         * trigger scrolling (defaults to 25)\r
-         * @type Number\r
-         */\r
-        hthresh : 25,\r
-\r
-        <div id="prop-Ext.dd.ScrollManager-increment"></div>/**\r
-         * The number of pixels to scroll in each scroll increment (defaults to 50)\r
-         * @type Number\r
-         */\r
-        increment : 100,\r
-        \r
-        <div id="prop-Ext.dd.ScrollManager-frequency"></div>/**\r
-         * The frequency of scrolls in milliseconds (defaults to 500)\r
-         * @type Number\r
-         */\r
-        frequency : 500,\r
-        \r
-        <div id="prop-Ext.dd.ScrollManager-animate"></div>/**\r
-         * True to animate the scroll (defaults to true)\r
-         * @type Boolean\r
-         */\r
-        animate: true,\r
-        \r
-        <div id="prop-Ext.dd.ScrollManager-animDuration"></div>/**\r
-         * The animation duration in seconds - \r
-         * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)\r
-         * @type Number\r
-         */\r
-        animDuration: .4,\r
-        \r
-        <div id="method-Ext.dd.ScrollManager-refreshCache"></div>/**\r
-         * Manually trigger a cache refresh.\r
-         */\r
-        refreshCache : function(){\r
-            for(var id in els){\r
-                if(typeof els[id] == 'object'){ // for people extending the object prototype\r
-                    els[id]._region = els[id].getRegion();\r
-                }\r
-            }\r
-        }\r
-    };\r
-}();</pre>
+<div id="cls-Ext.dd.ScrollManager"></div>/**
+ * @class Ext.dd.ScrollManager
+ * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>
+ * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,
+ * but you can also override most of the configs per scroll container by adding a 
+ * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},
+ * {@link #vthresh}, {@link #increment} and {@link #frequency}.  Example usage:
+ * <pre><code>
+var el = Ext.get('scroll-ct');
+el.ddScrollConfig = {
+    vthresh: 50,
+    hthresh: -1,
+    frequency: 100,
+    increment: 200
+};
+Ext.dd.ScrollManager.register(el);
+</code></pre>
+ * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>
+ * @singleton
+ */
+Ext.dd.ScrollManager = function(){
+    var ddm = Ext.dd.DragDropMgr;
+    var els = {};
+    var dragEl = null;
+    var proc = {};
+    
+    var onStop = function(e){
+        dragEl = null;
+        clearProc();
+    };
+    
+    var triggerRefresh = function(){
+        if(ddm.dragCurrent){
+             ddm.refreshCache(ddm.dragCurrent.groups);
+        }
+    };
+    
+    var doScroll = function(){
+        if(ddm.dragCurrent){
+            var dds = Ext.dd.ScrollManager;
+            var inc = proc.el.ddScrollConfig ?
+                      proc.el.ddScrollConfig.increment : dds.increment;
+            if(!dds.animate){
+                if(proc.el.scroll(proc.dir, inc)){
+                    triggerRefresh();
+                }
+            }else{
+                proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
+            }
+        }
+    };
+    
+    var clearProc = function(){
+        if(proc.id){
+            clearInterval(proc.id);
+        }
+        proc.id = 0;
+        proc.el = null;
+        proc.dir = "";
+    };
+
+    var startProc = function(el, dir){
+        clearProc();
+        proc.el = el;
+        proc.dir = dir;
+        var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,
+            freq  = (el.ddScrollConfig && el.ddScrollConfig.frequency)
+                  ? el.ddScrollConfig.frequency
+                  : Ext.dd.ScrollManager.frequency;
+
+        if (group === undefined || ddm.dragCurrent.ddGroup == group) {
+            proc.id = setInterval(doScroll, freq);
+        }
+    };
+    
+    var onFire = function(e, isDrop){
+        if(isDrop || !ddm.dragCurrent){ return; }
+        var dds = Ext.dd.ScrollManager;
+        if(!dragEl || dragEl != ddm.dragCurrent){
+            dragEl = ddm.dragCurrent;
+            // refresh regions on drag start
+            dds.refreshCache();
+        }
+        
+        var xy = Ext.lib.Event.getXY(e);
+        var pt = new Ext.lib.Point(xy[0], xy[1]);
+        for(var id in els){
+            var el = els[id], r = el._region;
+            var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
+            if(r && r.contains(pt) && el.isScrollable()){
+                if(r.bottom - pt.y <= c.vthresh){
+                    if(proc.el != el){
+                        startProc(el, "down");
+                    }
+                    return;
+                }else if(r.right - pt.x <= c.hthresh){
+                    if(proc.el != el){
+                        startProc(el, "left");
+                    }
+                    return;
+                }else if(pt.y - r.top <= c.vthresh){
+                    if(proc.el != el){
+                        startProc(el, "up");
+                    }
+                    return;
+                }else if(pt.x - r.left <= c.hthresh){
+                    if(proc.el != el){
+                        startProc(el, "right");
+                    }
+                    return;
+                }
+            }
+        }
+        clearProc();
+    };
+    
+    ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
+    ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
+    
+    return {
+        <div id="method-Ext.dd.ScrollManager-register"></div>/**
+         * Registers new overflow element(s) to auto scroll
+         * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either
+         */
+        register : function(el){
+            if(Ext.isArray(el)){
+                for(var i = 0, len = el.length; i < len; i++) {
+                       this.register(el[i]);
+                }
+            }else{
+                el = Ext.get(el);
+                els[el.id] = el;
+            }
+        },
+        
+        <div id="method-Ext.dd.ScrollManager-unregister"></div>/**
+         * Unregisters overflow element(s) so they are no longer scrolled
+         * @param {Mixed/Array} el The id of or the element to be removed or an array of either
+         */
+        unregister : function(el){
+            if(Ext.isArray(el)){
+                for(var i = 0, len = el.length; i < len; i++) {
+                       this.unregister(el[i]);
+                }
+            }else{
+                el = Ext.get(el);
+                delete els[el.id];
+            }
+        },
+        
+        <div id="prop-Ext.dd.ScrollManager-vthresh"></div>/**
+         * The number of pixels from the top or bottom edge of a container the pointer needs to be to
+         * trigger scrolling (defaults to 25)
+         * @type Number
+         */
+        vthresh : 25,
+        <div id="prop-Ext.dd.ScrollManager-hthresh"></div>/**
+         * The number of pixels from the right or left edge of a container the pointer needs to be to
+         * trigger scrolling (defaults to 25)
+         * @type Number
+         */
+        hthresh : 25,
+
+        <div id="prop-Ext.dd.ScrollManager-increment"></div>/**
+         * The number of pixels to scroll in each scroll increment (defaults to 100)
+         * @type Number
+         */
+        increment : 100,
+        
+        <div id="prop-Ext.dd.ScrollManager-frequency"></div>/**
+         * The frequency of scrolls in milliseconds (defaults to 500)
+         * @type Number
+         */
+        frequency : 500,
+        
+        <div id="prop-Ext.dd.ScrollManager-animate"></div>/**
+         * True to animate the scroll (defaults to true)
+         * @type Boolean
+         */
+        animate: true,
+        
+        <div id="prop-Ext.dd.ScrollManager-animDuration"></div>/**
+         * The animation duration in seconds - 
+         * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
+         * @type Number
+         */
+        animDuration: .4,
+        
+        <div id="prop-Ext.dd.ScrollManager-ddGroup"></div>/**
+         * The named drag drop {@link Ext.dd.DragSource#ddGroup group} to which this container belongs (defaults to undefined). 
+         * If a ddGroup is specified, then container scrolling will only occur when a dragged object is in the same ddGroup.
+         * @type String
+         */
+        ddGroup: undefined,
+        
+        <div id="method-Ext.dd.ScrollManager-refreshCache"></div>/**
+         * Manually trigger a cache refresh.
+         */
+        refreshCache : function(){
+            for(var id in els){
+                if(typeof els[id] == 'object'){ // for people extending the object prototype
+                    els[id]._region = els[id].getRegion();
+                }
+            }
+        }
+    };
+}();</pre>    
 </body>
 </html>
\ No newline at end of file