3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.dd.ScrollManager"></div>/**
\r
10 * @class Ext.dd.ScrollManager
\r
11 * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>
\r
12 * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,
\r
13 * but you can also override most of the configs per scroll container by adding a
\r
14 * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},
\r
15 * {@link #vthresh}, {@link #increment} and {@link #frequency}. Example usage:
\r
17 var el = Ext.get('scroll-ct');
\r
18 el.ddScrollConfig = {
\r
24 Ext.dd.ScrollManager.register(el);
\r
26 * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>
\r
29 Ext.dd.ScrollManager = function(){
\r
30 var ddm = Ext.dd.DragDropMgr;
\r
35 var onStop = function(e){
\r
40 var triggerRefresh = function(){
\r
41 if(ddm.dragCurrent){
\r
42 ddm.refreshCache(ddm.dragCurrent.groups);
\r
46 var doScroll = function(){
\r
47 if(ddm.dragCurrent){
\r
48 var dds = Ext.dd.ScrollManager;
\r
49 var inc = proc.el.ddScrollConfig ?
\r
50 proc.el.ddScrollConfig.increment : dds.increment;
\r
52 if(proc.el.scroll(proc.dir, inc)){
\r
56 proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
\r
61 var clearProc = function(){
\r
63 clearInterval(proc.id);
\r
70 var startProc = function(el, dir){
\r
74 var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
\r
75 el.ddScrollConfig.frequency : Ext.dd.ScrollManager.frequency;
\r
76 proc.id = setInterval(doScroll, freq);
\r
79 var onFire = function(e, isDrop){
\r
80 if(isDrop || !ddm.dragCurrent){ return; }
\r
81 var dds = Ext.dd.ScrollManager;
\r
82 if(!dragEl || dragEl != ddm.dragCurrent){
\r
83 dragEl = ddm.dragCurrent;
\r
84 // refresh regions on drag start
\r
88 var xy = Ext.lib.Event.getXY(e);
\r
89 var pt = new Ext.lib.Point(xy[0], xy[1]);
\r
91 var el = els[id], r = el._region;
\r
92 var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
\r
93 if(r && r.contains(pt) && el.isScrollable()){
\r
94 if(r.bottom - pt.y <= c.vthresh){
\r
96 startProc(el, "down");
\r
99 }else if(r.right - pt.x <= c.hthresh){
\r
101 startProc(el, "left");
\r
104 }else if(pt.y - r.top <= c.vthresh){
\r
106 startProc(el, "up");
\r
109 }else if(pt.x - r.left <= c.hthresh){
\r
111 startProc(el, "right");
\r
120 ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
\r
121 ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
\r
124 <div id="method-Ext.dd.ScrollManager-register"></div>/**
\r
125 * Registers new overflow element(s) to auto scroll
\r
126 * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either
\r
128 register : function(el){
\r
129 if(Ext.isArray(el)){
\r
130 for(var i = 0, len = el.length; i < len; i++) {
\r
131 this.register(el[i]);
\r
139 <div id="method-Ext.dd.ScrollManager-unregister"></div>/**
\r
140 * Unregisters overflow element(s) so they are no longer scrolled
\r
141 * @param {Mixed/Array} el The id of or the element to be removed or an array of either
\r
143 unregister : function(el){
\r
144 if(Ext.isArray(el)){
\r
145 for(var i = 0, len = el.length; i < len; i++) {
\r
146 this.unregister(el[i]);
\r
154 <div id="prop-Ext.dd.ScrollManager-vthresh"></div>/**
\r
155 * The number of pixels from the top or bottom edge of a container the pointer needs to be to
\r
156 * trigger scrolling (defaults to 25)
\r
160 <div id="prop-Ext.dd.ScrollManager-hthresh"></div>/**
\r
161 * The number of pixels from the right or left edge of a container the pointer needs to be to
\r
162 * trigger scrolling (defaults to 25)
\r
167 <div id="prop-Ext.dd.ScrollManager-increment"></div>/**
\r
168 * The number of pixels to scroll in each scroll increment (defaults to 50)
\r
173 <div id="prop-Ext.dd.ScrollManager-frequency"></div>/**
\r
174 * The frequency of scrolls in milliseconds (defaults to 500)
\r
179 <div id="prop-Ext.dd.ScrollManager-animate"></div>/**
\r
180 * True to animate the scroll (defaults to true)
\r
185 <div id="prop-Ext.dd.ScrollManager-animDuration"></div>/**
\r
186 * The animation duration in seconds -
\r
187 * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
\r
192 <div id="method-Ext.dd.ScrollManager-refreshCache"></div>/**
\r
193 * Manually trigger a cache refresh.
\r
195 refreshCache : function(){
\r
196 for(var id in els){
\r
197 if(typeof els[id] == 'object'){ // for people extending the object prototype
\r
198 els[id]._region = els[id].getRegion();
\r