3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 <div id="cls-Ext.dd.ScrollManager"></div>/**
16 * @class Ext.dd.ScrollManager
17 * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>
18 * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,
19 * but you can also override most of the configs per scroll container by adding a
20 * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},
21 * {@link #vthresh}, {@link #increment} and {@link #frequency}. Example usage:
23 var el = Ext.get('scroll-ct');
30 Ext.dd.ScrollManager.register(el);
32 * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>
35 Ext.dd.ScrollManager = function() {
36 var ddm = Ext.dd.DragDropMgr,
40 onStop = function(e) {
44 triggerRefresh = function() {
45 if (ddm.dragCurrent) {
46 ddm.refreshCache(ddm.dragCurrent.groups);
49 doScroll = function() {
50 if (ddm.dragCurrent) {
51 var dds = Ext.dd.ScrollManager,
52 inc = proc.el.ddScrollConfig ? proc.el.ddScrollConfig.increment: dds.increment;
54 if (proc.el.scroll(proc.dir, inc)) {
58 proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
62 clearProc = function() {
64 clearInterval(proc.id);
70 startProc = function(el, dir) {
74 var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
75 el.ddScrollConfig.frequency: Ext.dd.ScrollManager.frequency,
76 group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup: undefined;
78 if (group === undefined || ddm.dragCurrent.ddGroup == group) {
79 proc.id = setInterval(doScroll, freq);
82 onFire = function(e, isDrop) {
83 if (isDrop || !ddm.dragCurrent) {
86 var dds = Ext.dd.ScrollManager;
87 if (!dragEl || dragEl != ddm.dragCurrent) {
88 dragEl = ddm.dragCurrent;
89 // refresh regions on drag start
93 var xy = Ext.lib.Event.getXY(e),
94 pt = new Ext.lib.Point(xy[0], xy[1]),
100 if (els.hasOwnProperty(id)) {
103 c = el.ddScrollConfig ? el.ddScrollConfig: dds;
104 if (r && r.contains(pt) && el.isScrollable()) {
105 if (r.bottom - pt.y <= c.vthresh) {
107 startProc(el, "down");
110 } else if (r.right - pt.x <= c.hthresh) {
112 startProc(el, "left");
115 } else if (pt.y - r.top <= c.vthresh) {
120 } else if (pt.x - r.left <= c.hthresh) {
122 startProc(el, "right");
132 ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
133 ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
136 <div id="method-Ext.dd.ScrollManager-register"></div>/**
137 * 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)) {
144 for (; i < len; i++) {
145 this.register(el[i]);
153 <div id="method-Ext.dd.ScrollManager-unregister"></div>/**
154 * Unregisters overflow element(s) so they are no longer scrolled
155 * @param {Mixed/Array} el The id of or the element to be removed or an array of either
157 unregister: function(el) {
158 if (Ext.isArray(el)) {
161 for (; i < len; i++) {
162 this.unregister(el[i]);
170 <div id="prop-Ext.dd.ScrollManager-vthresh"></div>/**
171 * The number of pixels from the top or bottom edge of a container the pointer needs to be to
172 * trigger scrolling (defaults to 25)
176 <div id="prop-Ext.dd.ScrollManager-hthresh"></div>/**
177 * The number of pixels from the right or left edge of a container the pointer needs to be to
178 * trigger scrolling (defaults to 25)
183 <div id="prop-Ext.dd.ScrollManager-increment"></div>/**
184 * The number of pixels to scroll in each scroll increment (defaults to 50)
189 <div id="prop-Ext.dd.ScrollManager-frequency"></div>/**
190 * The frequency of scrolls in milliseconds (defaults to 500)
195 <div id="prop-Ext.dd.ScrollManager-animate"></div>/**
196 * True to animate the scroll (defaults to true)
201 <div id="prop-Ext.dd.ScrollManager-animDuration"></div>/**
202 * The animation duration in seconds -
203 * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
208 <div id="method-Ext.dd.ScrollManager-refreshCache"></div>/**
209 * Manually trigger a cache refresh.
211 refreshCache: function() {
214 if (els.hasOwnProperty(id)) {
215 if (typeof els[id] == 'object') {
216 // for people extending the object prototype
217 els[id]._region = els[id].getRegion();