dd-scroll.js revision 5b05d3439409acca6a1bd01f011571161e705d8e
4a14ce5ba00ab7bc55c99ffdcf59c7a4ab902721Automatic Updater * Base scroller class used to create the Plugin.DDNodeScroll and Plugin.DDWinScroll.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * This class should not be called on it's own, it's designed to be a plugin.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @module dd
6a42ab64276ff832a47e009be1208f7c7d4da22dAutomatic Updater * @submodule dd-scroll
6a42ab64276ff832a47e009be1208f7c7d4da22dAutomatic Updater * Base scroller class used to create the Plugin.DDNodeScroll and Plugin.DDWinScroll.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * This class should not be called on it's own, it's designed to be a plugin.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @class Scroll
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @extends Base
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @namespace DD
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @constructor
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews var S = function() {
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews S.superclass.constructor.apply(this, arguments);
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @attribute parentScroll
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @description Internal config option to hold the node that we are scrolling. Should not be set by the developer.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @type Node
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews return false;
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @attribute buffer
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @description The number of pixels from the edge of the screen to turn on scrolling. Default: 30
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @type Number
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @attribute scrollDelay
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @description The number of milliseconds delay to pass to the auto scroller. Default: 235
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @type Number
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @attribute host
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @description The host we are plugged into.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @type Object
cd791043c8a6edbcacc2392575a9816d19b8157cTinderbox User * @attribute windowScroll
cd791043c8a6edbcacc2392575a9816d19b8157cTinderbox User * @description Turn on window scroll support, default: false
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @type Boolean
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @attribute vertical
e839bf134fb138920d4833cf05cb8b8906787a8dAutomatic Updater * @description Allow vertical scrolling, default: true.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @type Boolean
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * @attribute horizontal
795a316ec568b2470aab18b9481443966047652eAutomatic Updater * @description Allow horizontal scrolling, default: true.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @type Boolean
795a316ec568b2470aab18b9481443966047652eAutomatic Updater * @property _scrolling
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @description Tells if we are actively scrolling or not.
795a316ec568b2470aab18b9481443966047652eAutomatic Updater * @type Boolean
6478b87fd23bcd3ab74c25b261021fe19a239c4fTinderbox User * @property _vpRegionCache
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * @description Cache of the Viewport dims.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * @type Object
ca67ebfe9eef0b8f04179f7e511a19e0337a5422Automatic Updater * @property _dimCache
ca67ebfe9eef0b8f04179f7e511a19e0337a5422Automatic Updater * @description Cache of the dragNode dims.
163af735c2082a024167be111d27bd5b5ff4f462Automatic Updater * @type Object
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @property _scrollTimer
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @description Holder for the Timer object returned from Y.later.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * @type {Y.later}
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * @method _getVPRegion
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * @description Sets the _vpRegionCache property with an Object containing the dims from the viewport.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User h.after('drag:start', Y.bind(this.start, this));
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews //TODO - This doesn't work yet??
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User Y.one('win').on('scroll', Y.bind(function() {
b27ce68bae92006e2ad7a9b75602c6385e529c3bAutomatic Updater * @method _checkWinScroll
922312472e2e05ebc64993d465999c5351b83036Automatic Updater * @description Check to see if we need to fire the scroll timer. If scroll timer is running this will scroll the window.
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews * @param {Boolean} move Should we move the window. From Y.later
582f8b9a8d170a80ef67475bddb8ad5cf7cd7cadMark Andrews var r = this._getVPRegion(),
if (move) {
this._cancelScroll();
if (scroll) {
this._initScroll();
this._cancelScroll();
_initScroll: function() {
this._cancelScroll();
this._scrollTimer = Y.Lang.later(this.get('scrollDelay'), this, this._checkWinScroll, [true], true);
_cancelScroll: function() {
this._scrolling = false;
if (this._scrollTimer) {
delete this._scrollTimer;
align: function(e) {
if (this._scrolling) {
this._cancelScroll();
e.preventDefault();
if (!this._scrolling) {
this._checkWinScroll();
_setDimCache: function() {
this._dimCache = {
start: function() {
this._setDimCache();
this._dimCache = null;
this._cancelScroll();
WS = function() {
windowScroll: {
value: true,
if (scroll) {
return scroll;
initializer: function() {
* @description The Scroll instance will be placed on the Drag instance under the winscroll namespace.
NS = function() {
node: {
value: false,
if (node !== false) {
initializer: function() {