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