dd-scroll.js revision c03d3f1eafc55ad0233f238f9ba1583c1e47fa96
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * Base scroller class used to create the Plugin.DDNodeScroll and Plugin.DDWinScroll.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * This class should not be called on it's own, it's designed to be a plugin.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @module dd
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @submodule dd-scroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * Base scroller class used to create the Plugin.DDNodeScroll and Plugin.DDWinScroll.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * This class should not be called on it's own, it's designed to be a plugin.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @class Scroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @extends Base
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @namespace DD
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @constructor
94bd918b63001277f1b28ae4581645f8a835688fBob Halley var S = function() {
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute parentScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Internal config option to hold the node that we are scrolling. Should not be set by the developer.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Node
94bd918b63001277f1b28ae4581645f8a835688fBob Halley return false;
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute buffer
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description The number of pixels from the edge of the screen to turn on scrolling. Default: 30
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Number
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute scrollDelay
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description The number of milliseconds delay to pass to the auto scroller. Default: 235
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Number
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute host
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description The host we are plugged into.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Object
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute windowScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Turn on window scroll support, default: false
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Boolean
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute vertical
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Allow vertical scrolling, default: true.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Boolean
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute horizontal
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Allow horizontal scrolling, default: true.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Boolean
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @property _scrolling
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Tells if we are actively scrolling or not.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Boolean
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @property _vpRegionCache
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Cache of the Viewport dims.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Object
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @property _dimCache
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Cache of the dragNode dims.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Object
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @property _scrollTimer
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Holder for the Timer object returned from Y.later.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type {Y.later}
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method _getVPRegion
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Sets the _vpRegionCache property with an Object containing the dims from the viewport.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley //TODO - This doesn't work yet??
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method _checkWinScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Check to see if we need to fire the scroll timer. If scroll timer is running this will scroll the window.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @param {Boolean} move Should we move the window. From Y.later
94bd918b63001277f1b28ae4581645f8a835688fBob Halley var r = this._getVPRegion(),
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method _initScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Cancel a previous scroll timer and init a new one.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley this._scrollTimer = Y.Lang.later(this.get('scrollDelay'), this, this._checkWinScroll, [true], true);
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method _cancelScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Cancel a currently running scroll timer.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley this._scrolling = false;
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method align
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Called from the drag:align event to determine if we need to scroll.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley align: function(e) {
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method _setDimCache
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Set the cache of the dragNode dims.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method start
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Called from the drag:start event
94bd918b63001277f1b28ae4581645f8a835688fBob Halley start: function() {
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method end
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Called from the drag:end event
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @method toString
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description General toString method for logging
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @return String name for the object
94bd918b63001277f1b28ae4581645f8a835688fBob Halley toString: function() {
94bd918b63001277f1b28ae4581645f8a835688fBob Halley return S.NAME + ' #' + this.get('node').get('id');
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * Extends the Scroll class to make the window scroll while dragging.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @class DDWindowScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @extends Scroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @namespace Plugin
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @constructor
94bd918b63001277f1b28ae4581645f8a835688fBob Halley WS = function() {
94bd918b63001277f1b28ae4581645f8a835688fBob Halley WS.superclass.constructor.apply(this, arguments);
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @attribute windowScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description Turn on window scroll support, default: true
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type Boolean
94bd918b63001277f1b28ae4581645f8a835688fBob Halley //Shouldn't have to do this..
94bd918b63001277f1b28ae4581645f8a835688fBob Halley this.set('windowScroll', this.get('windowScroll'));
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @property NS
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @default winscroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @protected
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @description The Scroll instance will be placed on the Drag instance under the winscroll namespace.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @type {String}
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * Extends the Scroll class to make a parent node scroll while dragging.
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @class DDNodeScroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @extends Scroll
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @namespace Plugin
94bd918b63001277f1b28ae4581645f8a835688fBob Halley * @constructor
94bd918b63001277f1b28ae4581645f8a835688fBob Halley NS = function() {
94bd918b63001277f1b28ae4581645f8a835688fBob Halley NS.superclass.constructor.apply(this, arguments);
node: {
value: false,
if (node !== false) {
initializer: function() {