1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-dd.ScrollManager'>/**
2 </span> * @class Ext.dd.ScrollManager
3 * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>
4 * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,
5 * but you can also override most of the configs per scroll container by adding a
6 * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},
7 * {@link #vthresh}, {@link #increment} and {@link #frequency}. Example usage:
8 * <pre><code>
9 var el = Ext.get('scroll-ct');
16 Ext.dd.ScrollManager.register(el);
17 </code></pre>
18 * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>
21 Ext.define('Ext.dd.ScrollManager', {
24 'Ext.dd.DragDropManager'
27 constructor: function() {
28 var ddm = Ext.dd.DragDropManager;
29 ddm.fireEvents = Ext.Function.createSequence(ddm.fireEvents, this.onFire, this);
30 ddm.stopDrag = Ext.Function.createSequence(ddm.stopDrag, this.onStop, this);
31 this.doScroll = Ext.Function.bind(this.doScroll, this);
32 this.ddmInstance = ddm;
39 var sm = Ext.dd.ScrollManager;
44 triggerRefresh: function() {
45 if (this.ddmInstance.dragCurrent) {
46 this.ddmInstance.refreshCache(this.ddmInstance.dragCurrent.groups);
50 doScroll: function() {
51 if (this.ddmInstance.dragCurrent) {
54 ddScrollConfig = proc.el.ddScrollConfig,
55 inc = ddScrollConfig ? ddScrollConfig.increment : this.increment;
58 if (procEl.scroll(proc.dir, inc)) {
59 this.triggerRefresh();
62 procEl.scroll(proc.dir, inc, true, this.animDuration, this.triggerRefresh);
67 clearProc: function() {
70 clearInterval(proc.id);
74 proc.dir = "";
77 startProc: function(el, dir) {
81 var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,
82 freq = (el.ddScrollConfig && el.ddScrollConfig.frequency)
83 ? el.ddScrollConfig.frequency
86 if (group === undefined || this.ddmInstance.dragCurrent.ddGroup == group) {
87 this.proc.id = setInterval(this.doScroll, freq);
91 onFire: function(e, isDrop) {
92 if (isDrop || !this.ddmInstance.dragCurrent) {
95 if (!this.dragEl || this.dragEl != this.ddmInstance.dragCurrent) {
96 this.dragEl = this.ddmInstance.dragCurrent;
97 // refresh regions on drag start
106 for (var id in els) {
107 var el = els[id], r = el._region;
108 var c = el.ddScrollConfig ? el.ddScrollConfig : this;
109 if (r && r.contains(pt) && el.isScrollable()) {
110 if (r.bottom - pt.y <= c.vthresh) {
112 this.startProc(el, "down");
115 }else if (r.right - pt.x <= c.hthresh) {
117 this.startProc(el, "left");
120 } else if(pt.y - r.top <= c.vthresh) {
122 this.startProc(el, "up");
125 } else if(pt.x - r.left <= c.hthresh) {
127 this.startProc(el, "right");
136 <span id='Ext-dd.ScrollManager-method-register'> /**
137 </span> * Registers new overflow element(s) to auto scroll
138 * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either
140 register : function(el){
141 if (Ext.isArray(el)) {
142 for(var i = 0, len = el.length; i < len; i++) {
143 this.register(el[i]);
147 this.els[el.id] = el;
151 <span id='Ext-dd.ScrollManager-method-unregister'> /**
152 </span> * Unregisters overflow element(s) so they are no longer scrolled
153 * @param {Mixed/Array} el The id of or the element to be removed or an array of either
155 unregister : function(el){
157 for (var i = 0, len = el.length; i < len; i++) {
158 this.unregister(el[i]);
162 delete this.els[el.id];
166 <span id='Ext-dd.ScrollManager-property-vthresh'> /**
167 </span> * The number of pixels from the top or bottom edge of a container the pointer needs to be to
168 * trigger scrolling (defaults to 25)
172 <span id='Ext-dd.ScrollManager-property-hthresh'> /**
173 </span> * The number of pixels from the right or left edge of a container the pointer needs to be to
174 * trigger scrolling (defaults to 25)
179 <span id='Ext-dd.ScrollManager-property-increment'> /**
180 </span> * The number of pixels to scroll in each scroll increment (defaults to 100)
185 <span id='Ext-dd.ScrollManager-property-frequency'> /**
186 </span> * The frequency of scrolls in milliseconds (defaults to 500)
191 <span id='Ext-dd.ScrollManager-property-animate'> /**
192 </span> * True to animate the scroll (defaults to true)
197 <span id='Ext-dd.ScrollManager-property-animDuration'> /**
198 </span> * The animation duration in seconds -
199 * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
204 <span id='Ext-dd.ScrollManager-property-ddGroup'> /**
205 </span> * The named drag drop {@link Ext.dd.DragSource#ddGroup group} to which this container belongs (defaults to undefined).
206 * If a ddGroup is specified, then container scrolling will only occur when a dragged object is in the same ddGroup.
211 <span id='Ext-dd.ScrollManager-method-refreshCache'> /**
212 </span> * Manually trigger a cache refresh.
214 refreshCache : function(){
218 if(typeof els[id] == 'object'){ // for people extending the object prototype
219 els[id]._region = els[id].getRegion();
224 </pre></pre></body></html>